According to this Rails guide, if you create a fixture, it becomes available in your test class.
I have this fixture in users.yml
:
<%
stan = User.new
stan.username = 'stan'
stan.set_hashed_password('mysterio')
stan.email = '[email protected]'
%>
stan:
username: <%= stan.username %>
hashed_password: <%= stan.hashed_password %>
password_salt: <%= stan.password_salt %>
email: <%= stan.email %>
Following the Rails guide, I'm trying to access it like this:
class SessionsControllerTest < ActionController::TestCase
@user = users(:stan)
# ...
end
I get this error:
./test/functional/sessions_controller_test.rb:5: undefined method `users' for SessionsControllerTest:Class (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in `require'