Strange unit test failure

I have two unit tests that works fine if I run them individually.

ex: ruby test/unit/company_test.rb
Loaded suite test/unit/company_test

Finished in 0.037888 seconds.

3 tests, 7 assertions, 0 failures, 0 errors

However, if I run ‘rake test:units’ the same test as above fails with:

  1. Failure:
    test_state(CompanyTest) [./test/unit/company_test.rb:26]:
    is not true.

My test is:
def test_state
# …
company = companies(:test_company)
assert company.valid?

Why would it work from ruby and not rake? I have one other test that
fails the same way.

Check what fixtures are being included in the tests. I’ve run into a lot
the same problems as this, and it’s always been that I wasn’t including
fixture properly.


Thanks. The issue seemed to be with one of the validations. I was
validating against a table of states using the two letter state abbr.
as a FK. When I took that validation out, the test worked in both
instances. In both cases, I loaded the fixture containing all the
state data. Feels to me like there might be a bug lurking in here
somewhere because the test should have worked in both cases.