I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2. I would like to use Selenium to test JavaScripts, but without deleting the test database data every time I run cucumber in a terminal window. That is, if I specify a function such as:
Feature: ... @javascript Scenario: ...
JavaScript is being tested as expected. However, after starting the test, the test database data is deleted, and I have to start this database again to run the new tests correctly.
I read the Official documentation and the text present in the file ROOT_APP/features/support/env.rb (it seems that I have installed all the necessary Ruby jewelry - see below for more information on the Gemfile that I use), but I did not understand how to avoid deleting database data and how to configure Cucumber and Capybara stones to work correctly with Selenium.
What should I do?
Note I: I would like to do the above because I would like to have the same test database data when I βtestedβ / βranβ the scripts.
Note II To sow data in the test database (my application needs this data to work), I add the following code to the file RAILS_ROOT_PATH/lib/tasks/cucumber.rake , and I run the rake db:test:prepare command line from the terminal window.
namespace :db do namespace :test do task :prepare => :environment do Rake::Task["db:seed"].invoke end end end
In the ROOT_APP/features/support/env.rb I tried to uncomment one and both of the following blocks of code (BTW: I never changed the source file automatically generated by the cucumber-rails stone, so it is standard), but after the tests run it still deletes test database data.
Excerpt from the Gemfile:
group :development, :test do gem "rspec-rails" end group :test do gem 'cucumber-rails' gem 'database_cleaner' gem 'capybara' end