Sha256: 54a0a9e6b1d183b23210f64fd441f003703579d6f3eec5fec0302b2a2a3b805a
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' describe DatabaseRewinder do before { DatabaseRewinder.init } describe '.[]' do before do DatabaseRewinder.instance_variable_set :'@db_config', {'foo' => {'adapter' => 'sqlite3', 'database' => ':memory:'}} DatabaseRewinder[:aho, connection: 'foo'] end subject { DatabaseRewinder.instance_variable_get(:'@cleaners').map {|c| c.connection_name} } it { should == ['foo'] } end describe '.record_inserted_table' do before do DatabaseRewinder.instance_variable_set :'@db_config', {'foo' => {'adapter' => 'sqlite3', 'database' => 'db/test.sqlite3'}} @cleaner = DatabaseRewinder.create_cleaner 'foo' connection = double('connection').as_null_object connection.instance_variable_set :'@config', {adapter: 'sqlite3', database: File.expand_path('db/test.sqlite3', Rails.root) } DatabaseRewinder.record_inserted_table(connection, 'INSERT INTO "foos" ("name") VALUES (?)') end subject { @cleaner } its(:inserted_tables) { should == ['foos'] } end describe '.clean' do before do Foo.create! name: 'foo1' Bar.create! name: 'bar1' DatabaseRewinder.clean end it 'should clean' do Foo.count.should == 0 Bar.count.should == 0 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
database_rewinder-0.0.2 | spec/database_rewinder_spec.rb |