fixes build by fixes Sequel adapter
This commit is contained in:
parent
18108d775a
commit
4c92da608a
|
@ -15,7 +15,7 @@ module DatabaseCleaner
|
|||
def db
|
||||
return @db if @db && @db != :default
|
||||
raise "As you have more than one active sequel database you have to specify the one to use manually!" if ::Sequel::DATABASES.count > 1
|
||||
::Sequel::DATABASES.first
|
||||
::Sequel::DATABASES.first || :default
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,18 +32,14 @@ module DatabaseCleaner
|
|||
it "should truncate all tables except for schema_migrations" do
|
||||
connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
|
||||
|
||||
connection.should_receive(:truncate_table).with('widgets')
|
||||
connection.should_receive(:truncate_table).with('dogs')
|
||||
connection.should_not_receive(:truncate_table).with('schema_migrations')
|
||||
|
||||
connection.should_receive(:truncate_tables).with(['widgets', 'dogs'])
|
||||
Truncation.new.clean
|
||||
end
|
||||
|
||||
it "should only truncate the tables specified in the :only option when provided" do
|
||||
connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
|
||||
|
||||
connection.should_receive(:truncate_table).with('widgets')
|
||||
connection.should_not_receive(:truncate_table).with('dogs')
|
||||
connection.should_receive(:truncate_tables).with(['widgets'])
|
||||
|
||||
Truncation.new(:only => ['widgets']).clean
|
||||
end
|
||||
|
@ -51,8 +47,7 @@ module DatabaseCleaner
|
|||
it "should not truncate the tables specified in the :except option" do
|
||||
connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
|
||||
|
||||
connection.should_receive(:truncate_table).with('dogs')
|
||||
connection.should_not_receive(:truncate_table).with('widgets')
|
||||
connection.should_receive(:truncate_tables).with(['dogs'])
|
||||
|
||||
Truncation.new(:except => ['widgets']).clean
|
||||
end
|
||||
|
@ -71,8 +66,7 @@ module DatabaseCleaner
|
|||
connection.stub!(:tables).and_return(%w[widgets dogs])
|
||||
connection.stub!(:views).and_return(["widgets"])
|
||||
|
||||
connection.should_receive(:truncate_table).with('dogs')
|
||||
connection.should_not_receive(:truncate_table).with('widgets')
|
||||
connection.should_receive(:truncate_tables).with(['dogs'])
|
||||
|
||||
Truncation.new.clean
|
||||
end
|
||||
|
|
|
@ -17,6 +17,7 @@ module DatabaseCleaner
|
|||
Temp_MM = ::MongoMapper if defined?(::MongoMapper) and not defined?(Temp_MM)
|
||||
Temp_MO = ::Mongoid if defined?(::Mongoid) and not defined?(Temp_MO)
|
||||
Temp_CP = ::CouchPotato if defined?(::CouchPotato) and not defined?(Temp_CP)
|
||||
Temp_SQ = ::Sequel if defined?(::Sequel) and not defined?(Temp_SQ)
|
||||
end
|
||||
|
||||
#Remove all ORM mocks and restore from cache
|
||||
|
@ -26,6 +27,7 @@ module DatabaseCleaner
|
|||
Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper)
|
||||
Object.send(:remove_const, 'Mongoid') if defined?(::Mongoid)
|
||||
Object.send(:remove_const, 'CouchPotato') if defined?(::CouchPotato)
|
||||
Object.send(:remove_const, 'Sequel') if defined?(::Sequel)
|
||||
|
||||
|
||||
# Restore ORMs
|
||||
|
@ -43,6 +45,7 @@ module DatabaseCleaner
|
|||
Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper)
|
||||
Object.send(:remove_const, 'Mongoid') if defined?(::Mongoid)
|
||||
Object.send(:remove_const, 'CouchPotato') if defined?(::CouchPotato)
|
||||
Object.send(:remove_const, 'Sequel') if defined?(::Sequel)
|
||||
end
|
||||
|
||||
let(:cleaner) { DatabaseCleaner::Base.new :autodetect }
|
||||
|
@ -57,6 +60,7 @@ module DatabaseCleaner
|
|||
Object.const_set('MongoMapper', 'Mapping mock mongos')
|
||||
Object.const_set('Mongoid', 'Mongoid mock')
|
||||
Object.const_set('CouchPotato', 'Couching mock potatos')
|
||||
Object.const_set('Sequel', 'Sequel mock')
|
||||
|
||||
cleaner.orm.should == :active_record
|
||||
cleaner.should be_auto_detected
|
||||
|
@ -67,6 +71,7 @@ module DatabaseCleaner
|
|||
Object.const_set('MongoMapper', 'Mapping mock mongos')
|
||||
Object.const_set('Mongoid', 'Mongoid mock')
|
||||
Object.const_set('CouchPotato', 'Couching mock potatos')
|
||||
Object.const_set('Sequel', 'Sequel mock')
|
||||
|
||||
cleaner.orm.should == :data_mapper
|
||||
cleaner.should be_auto_detected
|
||||
|
@ -76,6 +81,7 @@ module DatabaseCleaner
|
|||
Object.const_set('MongoMapper', 'Mapping mock mongos')
|
||||
Object.const_set('Mongoid', 'Mongoid mock')
|
||||
Object.const_set('CouchPotato', 'Couching mock potatos')
|
||||
Object.const_set('Sequel', 'Sequel mock')
|
||||
|
||||
cleaner.orm.should == :mongo_mapper
|
||||
cleaner.should be_auto_detected
|
||||
|
@ -84,17 +90,26 @@ module DatabaseCleaner
|
|||
it "should detect Mongoid fourth" do
|
||||
Object.const_set('Mongoid', 'Mongoid mock')
|
||||
Object.const_set('CouchPotato', 'Couching mock potatos')
|
||||
Object.const_set('Sequel', 'Sequel mock')
|
||||
|
||||
cleaner.orm.should == :mongoid
|
||||
cleaner.should be_auto_detected
|
||||
end
|
||||
|
||||
it "should detect CouchPotato last" do
|
||||
it "should detect CouchPotato fifth" do
|
||||
Object.const_set('CouchPotato', 'Couching mock potatos')
|
||||
Object.const_set('Sequel', 'Sequel mock')
|
||||
|
||||
cleaner.orm.should == :couch_potato
|
||||
cleaner.should be_auto_detected
|
||||
end
|
||||
|
||||
it "should detect Sequel last" do
|
||||
Object.const_set('Sequel', 'Sequel mock')
|
||||
|
||||
cleaner.orm.should == :sequel
|
||||
cleaner.should be_auto_detected
|
||||
end
|
||||
end
|
||||
|
||||
describe "orm_module" do
|
||||
|
|
Loading…
Reference in New Issue