views:

21

answers:

1

The system I'm testing is complex enough where writing separated test cases would be a huge waste of time and resources. So, I need my tests to build off each other.

But, for example, whenever I got User.new in one of my step definitions, once the scenario is done, the User is removed from the DB.

How do I keep all my information... unless I force a db:test:prepare?

This is my env.rb:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')

require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'
require 'cucumber/rails/rspec' 
require 'rake'



require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :transaction

@subscription_plan = Factory(:subscription_plan)
@subscription_plan.save!

Capybara.default_selector = :css
Capybara.default_wait_time = 2
Capybara.javascript_driver = :culerity
Capybara.current_driver = :culerity
Capybara.default_host = "cucumber.test.com" #for Rack::Test
Capybara.app_host = "cucumber.test.com" #if Capybara.current_driver == :culerity

Cucumber::Rails::World.use_transactional_fixtures = false
A: 

In features/support/env.rb should be a line:

Cucumber::Rails::World.use_transactional_fixtures = true

Set that to false, and your database truncation should cease.

Edit: Since this failed, try adding the tag @no-txn to feature files that require data to persist; it seems like this is a reserved tag used by Cucumber to cause scenarios to not be wrapped in a transaction.

davidcelis
I added my env.rb file. My DB is still missing data ... le boo. T_T
DerNalia
Try adding the tag @no-txn to feature files that require data to persist; it seems like this is a reserved tag used by Cucumber to cause scenarios to not be wrapped in a transaction.
davidcelis
@no-txn didn't work =\ this is really weird
DerNalia
Just noticed the lines in your env.rb file relating to DatabaseCleaner... try commenting them out (the lines such as "require 'database_cleaner'", etc.
davidcelis