我正在尝试使用 rails 5.0.1 中的固定装置为我的数据库编写单元测试。
我不断收到错误:
test/test_helper.rb:7:in `<class:TestCase>': undefined method `fixtures' for ActiveSupport::TestCase:Class (NoMethodError)
from /Users/Stephan/ruby/react/test/test_helper.rb:5:in `<top (required)>'
from /Users/Stephan/ruby/react/test/models/blog_test.rb:1:in `require'
from /Users/Stephan/ruby/react/test/models/blog_test.rb:1:in `<top (required)>'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `require'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `each'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:86:in `plugin_rails_init'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/minitest-5.10.1/lib/minitest.rb:80:in `block in init_plugins'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/minitest-5.10.1/lib/minitest.rb:78:in `each'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/minitest-5.10.1/lib/minitest.rb:78:in `init_plugins'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/minitest-5.10.1/lib/minitest.rb:129:in `run'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:73:in `run'
from /Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/minitest-5.10.1/lib/minitest.rb:62:in `block in autorun'
test_helper.rb 中的所有内容都是开箱即用的 ruby 2.4.0 和 rails 5.0.1。
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
任何帮助,将不胜感激。这里的参考是 test_helper.rb 文件