>> > Alright. Here's one roadblock.
>> > So what I understand w/BDD is that I should write all these tests,
>> > watch them fail, and then code to make the tests pass.
>> No. Write *one* test, watch it fail, make it pass, refactor as
>> necessary. Then write the next test. Lather, rinse, repeat.
> Does this apply to all tests - unit, functional, etc? I got my unit
> tests working, but my functionals are not.
Yes. One test at a time on each level. Also, Test::Unit functionals
are needlessly painful. Use Cucumber instead.
Okay. Shoulda / Test::Unit in functional tests are painful... I'll
get back to you on Cucumber.
My usual procedure:
Write a Cucumber story for functionality, watch it fail.
Figure out the first thing I need to do to implement that functionality,
write a unit spec in RSpec, watch it fail, make it pass.
Do next unit spec likewise.
When Cucumber story passes, feature is complete. Write another story.
Instead of RSpec, is it okay to use Shoulda (with Cucumber, I mean)?
All I see, including in the Rails 3 installation instructions here...
https://github.com/aslakhellesoy/cucumber-rails/blob/master/README.rdoc
... are instructions involving RSpec only. Bleh.
Should I get acquainted with RSpec?
Actually, can't Shoulda and RSpec work together?
There's got to be some down-to-earth tutorial about all this...
>> > But the error
>> > messages I get from running tests don't provide as much insight as
>> > doing "rails server" and then seeing whatever error comes up... I
>> > don't understand how people do this.
>> Probably by writing more atomic tests. Could you give an example test
>> that wasn't as useful as you would have liked?
> Sure. Navigating to a sections#show page yields a screen that says
> "NoMethodError in SectionsController#show
> undefined method `paginate' for #<Class:0x5eb4ad0>"
> so I immediately realize I need to check wherever I call paginate and
> see if the method is implemented.
> Running the functional test
> ruby -I test test/functional/sections_controller_test.rb
> Only yields this:
> 1) Error:
> test: A section should respond with 200.
"A section"? Which one? Make your descriptions more explicit.
> (SectionsControllerTest):
> NoMethodError: undefined method `response_code' for nil:NilClass
> This doesn't mean anything to me.
How can that not mean anything to you, when it's telling you exactly
what the error is?
All this error tells me is that something that is nil is trying to
call response_code. The error I get with rails server and browsing to
the page is
undefined method `paginate' for #<Class:0x5eb4ad0>" which tells me
that I have to check out the paginate method - something much more
direct/useful!!!
> (In my test, I had should
> respond_with :success.)
You can step through with the debugger to see where it fails.
Also, RSpec and Cucumber have better error reporting than Test::Unit.
ohhh I hope so.
So from here, I'll try to get Cucumber working for my functional
tests... Is cucumber ONLY for functionals, or integration/others too?
I have shoulda working for unit tests...