As mentioned in another post recently, I have been trying to get Rails 3
and MongoDB working, firstly by following this handy document:
Having done this, I found that the scaffold functional test code
contained the following:
class JobsControllerTest < ActionController::TestCase
@job = jobs(:one)
# …. various basic tests here
I have defined a "one" job in jobs.yml. However, attempting to run tests
gives me such errors as:
NoMethodError: undefined method `jobs' for
If I understand correctly, this would suggest that the jobs.yml fixture
has not been loaded. Adding "fixtures :all" to test/test_helper.rb
simply produces NoMethodErrors for "fixtures". I'm not getting any
test.log entries to assist in debugging this, but I think that the
database connection is working as the app, running in a development
environment, successfully interacts with the development database.
Have I missed something vital out when doing the initial app setup,
My only suggestion now would be that fixtures is part of ActiveRecord.
It looks like you're right - thanks. Simply including fixtures.rb
doesn't appear to work as it requires ActiveRecord::Base, which it seems
I can't also use if sticking to those instructions. I suspect that I'll
have to find another means to run the tests, avoiding fixtures.
It seems that factory_girl does indeed work. I didn't have to do much
other than create a test/factory.rb, include this in
test/test_helper.rb, and add to the latter some code to clear out the
test database after testing.