Just wondering if anyone knows any plugins that make rspec controller
testing more concise rather then repeating heaps of code for every
action?
Would love to hear some thoughts on controller and view testing and
what everyone tests out there.
Thanks,
Carl.
--
Carl Woodward
0412218979
cjwoo...@gmail.com
http://blog.davidchelimsky.net/2008/7/1/new-controller-examples
>
> Would love to hear some thoughts on controller and view testing and
> what everyone tests out there.
>
> Thanks,
> Carl.
>
> --
> Carl Woodward
> 0412218979
> cjwoo...@gmail.com
>
> >
>
--
:lachie
http://smartbomb.com.au
http://www.flickr.com/photos/lachie/
Thats the way that I am writing them. I feel like I am writing nice
tight controller code and 3 times the test code, but not because its
tested in multiple ways or scenarios but because the test code is
longer.
Any thoughts?
Thanks,
Carl.
Well David's point (if i understand it) is that writing a bit more
clearly will make your specs less brittle when things change
you could also try rr for much terser mock syntax:
http://github.com/btakita/rr/tree/master
it "should be successful" do
response.should be_success
end
be
it_should_be_successful
and
it "should render edit template" do
response.should render_template('edit')
end
be
it_should_render_edit_template
I'm just looking at getting rid of lines.
I'm trying to implement this now. Would love to know peoples throughts.
Ideally you would then have a couple of lines of it should do response stuff
and then your mocking functionality. Maybe I'm being silly. I do like typing...
2008/8/29 Xavier Shay <xavie...@rhnh.net>:
--
Enrico Teotti
IT consultant, accessible web sites and web applications
Sydney, NSW, Australia
enrico...@gmail.com
mobile (IT) +393286590765
mobile (AU) +00610416748450
Why couldn't:
it "should be successful" do
response.should be_success
end
be
it_should_be_successful
and
it "should render edit template" do
response.should render_template('edit')
end
be
it_should_render_edit_template
and basically only write tests for what "makes your controller
special"... It's nobody's fault, but controllers are currently _not_
DRY IMHO.
Best,
-Adam
Rails has just gone the reverse direction with Test::Unit.
http://github.com/rails/rails/commit/f74ba37f4e4175d5a1b31da59d161b0020b58e94
-Adam
Why couldn't:
it "should be successful" do
response.should be_success
end
be
it_should_be_successful
describe "a typical controller", :shared => true do
def self.it_should_be_successful
it "should be successful" do
response.should be_success
end
end
end
describe "MyController" do
it_should_behave_like "a typical controller"
it_should_be_successful
end
describe "a typical controller", :shared => true do
it "should be successful" do
response.should be_success
end
end
describe "MyController" do
it_should_behave_like "a typical controller"
end