我試圖在我的rails3應用程序中實現一些單元測試。以下是我的'test_helper.rb
'文件。Rails 3中的單元測試錯誤
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
include Devise::TestHelpers
fixtures :all
end
關注我的fixture文件(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>
和下面是我的單元測試類
require 'test_helper'
class SiteLayoutTest < Test::Unit::TestCase
fixtures :site_layouts
test "show site layout" do
layout = site_layouts(:one)
end
end
,當我嘗試運行rake test:units
我發現了以下錯誤
undefined method `fixtures' for SiteLayoutTest:Class (NoMethodError)
我有點新的測試。我在
- 的Rails 3.0.0
- Linux的
- 測試單元(2.4.1,2.4.0,2.3.2,1.2.3)
- 測試單位通知( 0.3.0)
謝謝ream88,你是對的 – sameera207