我可能缺少一些东西,但我设置了以下 rake 任务:
namespace :test do
Rake::TestTask.new(:acceptance => "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/acceptance/**/*_test.rb'
end
end
我正在使用 Capybara 进行验收测试,因此我还在我的test_helper.rb
文件中包含了以下代码:
DatabaseCleaner.strategy = :truncation
class ActionDispatch::IntegrationTest
# Make the Capybara DSL available in all integration tests
include Capybara::DSL
# Stop ActiveRecord from wrapping tests in transactions
self.use_transactional_fixtures = false
# Always use Selenium
Capybara.default_driver = :selenium
teardown do
DatabaseCleaner.clean # Truncate the database
Capybara.reset_sessions! # Forget the (simulated) browser state
Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
end
end
不幸的是,当我运行rake test:acceptance
时,当 rake 尝试运行一个名为的玩具测试时,我收到以下错误selenium_test.rb
:
.../test/acceptance/selenium_test.rb:1:in `<top (required)>': uninitialized constant ActionDispatch (NameError)
该文件selenium_test.rb
位于test/acceptance
应用程序的文件夹中。如果我将它移到test/functional
,它运行得很好。
任何帮助将不胜感激。