Wednesday, April 7, 2010

Rspec Matchers you'll usually use

should ==   # there's also should eql and should equal which compares only the values (not the identity)
should_not ==
should be_nil
should_not be_nil
should be_true
should_not be_true
should be_empty
should_not be_empty
should be_valid
should_not be_validshould include


Always use should_not rather than negating whatever follows it.  And it's also good practice to have one expectation per example (with exceptions, i think). Isn't testing tedious?

To run tests automatically, use autospec.

No comments:

Post a Comment