开发者

FixtureReplacement with Cucumber

I am using Cucumber with Selenium, FixtureReplacement and DatabaseCleaner.

Funnily enough, my data I created with FixtureReplacement is not accessible from my tests.

I have added an own rails environment for selenium and I am using an own profile for my enhanced selenium fea开发者_如何学Pythontures. My cucumber setup for the selenium profile is:

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 works well, I have tested it in the Rails console.

I am running my selenium features with:

RAILS_ENV=selenium cucumber -p selenium features/enhanced/test.feature

Does anybody know a solution to this problem?

Best regards


I wonder if you are using Database Cleaner correctly? In my env.rb, I am using it like this:

Before do
  require 'database_cleaner'
  require 'database_cleaner/cucumber'
  DatabaseCleaner.strategy = :truncation
end

This works for me when using Factory Girl.


This had nothing to do with Fixtures. I thought I cannot access my data, because I couldn't login.

The following fixed it: Cucumber + selenium fails randomly

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜