I am writing my first tests using Test: Unit and Shoulda, so this may be a simple misunderstanding on my part, but given the Pages model, which does not contain validation, and the test:
The second test fails as expected (in the absence of validation in the model):
# Running tests: [2/2] PageTest#test: Page should require slug to be set. = 0.02 s 1) Failure: test: Page should require slug to be set. (PageTest) [/Users/Matt/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/shoulda-context-1.1.1/lib/shoulda/context/context.rb:339]: Did not expect errors to include "can't be blank" when slug is set to nil, got error: Finished tests in 0.115436s, 17.3256 tests/s, 17.3256 assertions/s. 2 tests, 2 assertions, 1 failures, 0 errors, 0 skips
However, the error message Did not expect errors to include "can't be blank" when slug is set to nil seems Did not expect errors to include "can't be blank" when slug is set to nil be reversed. You should not read: Expected errors to include "can't be blank" because if the check I'm testing for existence, you expect an error from checking that slug "cannot be empty" when slug is nil.
The test passes if I add confirmation, but first I want it to work correctly!
Also, why does the first test pass? My Pages model does not contain belongs_to association!
Testing sucks !: - (
source share