I have written cucumber test cases and now i need to rollback database not the existing one. I have use selenium web-driver with capybara 2.0.2. When i have tried with:
DatabaseCleaner[:active_record].strategy = :truncation
It is deleted all records of my mysql table. Afterwards i have changed this is by:
DatabaseCleaner[:active_record].strategy = :transaction
But this is not rolling database.
My database.rb is:
require 'active_record'
require 'database_cleaner'
require 'database_cleaner/cucumber'
ActiveRecord::Base.establish_connection(
:adapter => 'mysql2',
:database => 'aq_test',
:username => 'root',
:password => 'manager' )
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
DatabaseCleaner[:active_record].strategy = :transaction
But this is also not roll back the databases Note: I want only to rollback last transaction which is run by test cases
Sorry for my english