views:

447

answers:

2

Hi,

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

+1  A: 

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.

Rodreegez
This also does not work for me. Can you post your whole Cucumber setup?
brainfck
BTW, I have changed to Factory Girl.
brainfck
Here's a gist: http://gist.github.com/215924Basically:* Run features in the test env (perhapsnot a great idea)* Turn off transactional fixtures * Configure Webrat to use selenium (with a few additional config options specific to my setup) * Require Factory Girl (perhaps the bit you are missing?)* Define Database cleaner in a Before hook.Hope that helps, Ad.
Rodreegez
+1  A: 

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

The following fixed it: http://stackoverflow.com/questions/966052/cucumber-selenium-fails-randomly/966998#966998

brainfck