【发布时间】:2014-01-22 12:07:59
【问题描述】:
我在使用时遇到了问题:
- 导轨 (3.2)
- Rspec (2.14.1)
- 数据库清理器 (1.2.0)
这就是我的 Rspec 配置的样子:
RSpec.configure do |config|
config.include Capybara::DSL
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
我会在我的before(:each) 块中创建记录,但我不会在我的应用程序代码中看到它们。
这会导致问题,因为我预计不存在的对象。
经过多次尝试,我终于找到了问题的答案。
【问题讨论】:
标签: ruby-on-rails selenium rspec database-cleaner