我将 Cucumber 与 Selenium、FixtureReplacement 和 DatabaseCleaner 一起使用。
有趣的是,我使用 FixtureReplacement 创建的数据无法从我的测试中访问。
我为 selenium 添加了自己的 rails 环境,并且我正在使用自己的配置文件来增强 selenium 功能。我的硒配置文件的黄瓜设置是:
Webrat.configure do |config|
config.mode = :selenium
config.application_environment = :selenium
end
Cucumber::Rails::World.use_transactional_fixtures = false
require "database_cleaner"
# Clean the database once when starting
DatabaseCleaner.clean_with :truncation
DatabaseCleaner.strategy = :truncation
Before do
DatabaseCleaner.start
include FixtureReplacement
end
After do
DatabaseCleaner.clean
end
# this is necessary to have webrat "wait_for" the response body to be available
# when writing steps that match against the response body returned by selenium
World(Webrat::Selenium::Matchers)
FixtureReplacement 效果很好,我已经在 Rails 控制台中对其进行了测试。
我正在运行我的硒功能:
RAILS_ENV=selenium cucumber -p selenium features/enhanced/test.feature
有人知道这个问题的解决方案吗?
最好的祝福