Rails Testing Notes
Okay, so there is a little ambiguity on a few things that shoulda and rails testing does for you:
XUnit Testing Frameworks 101:
-setup and teardown methods run before and after (respectively) EACH test method in a TestCase or shoulda context gets run, not once at the beginning of the context/TestCase and once at the end
They are tremendously useful for avoiding code duplication and making your test cases read easier.
(gleaned from reading and analyzing source)
-Rails unit and functional tests have a top level parent that extends Test::Unit::TestCase (part of the ruby standard lib)
http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/TestCase.html
The core concept behind this testing methodology is here--also mentioned in the Programming Ruby book--understand it.
should_eventually "be the best dang program in the whole world" do
end
is how you specify test cases you haven't written yet, but you know you'll need them...
(gleaned from shoulda source code inspection)
Mocha/Mocking/Stubing
http://mocha.rubyforge.org/
- This mock/stub framework is awesome. Make sure you understand how to:
Object#stubs
Object#expects and all of the goodies in Mocha::Expectation (especially never, raises, once methods)
Class.any_instance