I'm trying to implement some unit tests in my rails3 application. The following is my 'test_helper.rb
' file.
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
include Devise::TestHelpers
fixtures :all
end
Following my fixture file (site_layouts.yml
)
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
name: layout1
content: <html><head></head><body>layout1</body></html>
two:
name: layout2
content: <html><head></head><body>layout2</body></html>
and following is my Unit test class
require 'test_helper'
class SiteLayoutTest < Test::Unit::TestCase
fixtures :site_layouts
test "show site layout" do
layout = site_layouts(:one)
end
end
and when I try to run the rake test:units
I'm getting the following error
undefined method `fixtures' for SiteLayoutTest:Class (NoMethodError)
I'm a little new to testing. I'm on
I think you don't need the fixtures :site_layouts
call inside SiteLayoutTest
. Rails should auto load your fixtures.
More about fixtures in the Rails Guides.