Question

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 features. 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

Was it helpful?

Solution 2

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top