Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6778113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:13:42+00:00 2026-05-26T16:13:42+00:00

I am using cucumber + capybara for my tests.The database cleaner is working good,

  • 0

I am using cucumber + capybara for my tests.The database cleaner is working good, but when I change the Capybara.default_driver to selenium, database cleaner is not working. Below is my env.rb file.

Capybara.default_selector = :css
Capybara.default_driver = :selenium
Capybara.javascript_driver = :selenium
ActionController::Base.allow_rescue = false
Cucumber::Rails::World.use_transactional_fixtures = true

if defined?(ActiveRecord::Base)
  begin
    require 'database_cleaner'
    DatabaseCleaner.strategy = :truncation
  rescue LoadError => ignore_if_database_cleaner_not_present
  end
end

OmniAuth.config.test_mode = true
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:13:43+00:00Added an answer on May 26, 2026 at 4:13 pm

    From the database_cleaner documentation, hope it helps:

    One of my motivations for writing this library was to have an easy way
    to turn on what Rails calls “transactional_fixtures” in my non-rails
    ActiveRecord projects. For example, Cucumber ships with a Rails world
    that will wrap each scenario in a transaction. This is great, but what
    if you are using ActiveRecord in a non-rails project? You used to have
    to copy-and-paste the needed code, but with DatabaseCleaner you can
    now say:

    #env.rb

       require 'database_cleaner'
       require 'database_cleaner/cucumber'
       DatabaseCleaner.strategy = :transaction
    

    Now lets say you are running your features and it requires that
    another process be involved (i.e. Selenium running against your app’s
    server.) You can simply change your strategy type:

    #env.rb

    require 'database_cleaner'
    require 'database_cleaner/cucumber'
    DatabaseCleaner.strategy = :truncation
    

    You can have the best of both worlds and use the best one for the job:

    #env.rb

    require 'database_cleaner' 
    require 'database_cleaner/cucumber'
    
    DatabaseCleaner.strategy = (ENV['SELENIUM'] == 'true') ? :truncation : :transaction
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to test an inplace editor using Cucumber/Capybara/Selenium stack, but my problem
If I'm using cucumber/capybara with a selenium web driver to test, do I need
I'm trying to test the authenticate_or_request_with_http_basic method using Cucumber and Capybara, but it doesn't
When using Cucumber with Capybara, I have to load test database data from SQL
I am using capybara and cucumber in my rails3 application. Everything is working just
I am using capybara and selenium to run my cucumber test on my local
I'm working on a rails project using, cucumber, capybara and factory girl, and recently
I am using Ruby on Rails with Cucumber and Capybara. How would I go
I'm using Cucumber and Capybara and I'd like a way to simulate the request
I'm running some tests with Cucumber/Capybara. I've got one scenario where the user goes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.