如果我使用rake cucumber
,则未加载灯具且我的测试失败。如果我使用cucumber --tag @tagname
来运行场景,它会加载灯具,工厂,并且一切都会通过。
/features/support/env.rb
的底部如下所示:
Cucumber::Rails::World.use_transactional_fixtures = true
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, 'spec', 'fixtures')
fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') }
Fixtures.create_fixtures(fixtures_folder, fixtures)
if defined?(ActiveRecord::Base)
begin
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
rescue LoadError => ignore_if_database_cleaner_not_present
end
end
其他一切都是相当标准的Rails 3。
答案 0 :(得分:0)
我不得不改变这一行:
DatabaseCleaner.strategy = :truncation, {:except => %w[degrees states_provinces contribution_types manuscript_types statuses countries roles user_templates]}
我需要为测试加载的所有表都要通过,但DatabaseCleaner在每个场景后都会截断它们。