kills whitespace

This commit is contained in:
Ben Mabey 2010-08-23 14:50:32 -06:00
parent 43636b7cc9
commit 8b94d1928d
12 changed files with 96 additions and 96 deletions

View File

@ -20,4 +20,4 @@ end
Then /^I should see ([\d]+) widget in another db using mongoid$/ do |widget_count| Then /^I should see ([\d]+) widget in another db using mongoid$/ do |widget_count|
MongoidWidgetUsingDatabaseTwo.count.should == widget_count.to_i MongoidWidgetUsingDatabaseTwo.count.should == widget_count.to_i
end end

View File

@ -38,7 +38,7 @@ if orm && strategy
if multiple_db if multiple_db
DatabaseCleaner.app_root = "#{File.dirname(__FILE__)}/../.." DatabaseCleaner.app_root = "#{File.dirname(__FILE__)}/../.."
orm_sym = orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym orm_sym = orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym

View File

@ -46,4 +46,4 @@ class MongoidWidgetUsingDatabaseTwo
new(*args).save! new(*args).save!
end end
end end
end end

View File

@ -13,21 +13,21 @@ class FeatureRunner
def go(feature) def go(feature)
full_dir ||= File.expand_path(File.dirname(__FILE__) + "/../../examples/") full_dir ||= File.expand_path(File.dirname(__FILE__) + "/../../examples/")
Dir.chdir(full_dir) do Dir.chdir(full_dir) do
ENV['ORM'] = orm ENV['ORM'] = orm
ENV['STRATEGY'] = strategy ENV['STRATEGY'] = strategy
if another_orm if another_orm
ENV['ANOTHER_ORM'] = another_orm ENV['ANOTHER_ORM'] = another_orm
else else
ENV['ANOTHER_ORM'] = nil ENV['ANOTHER_ORM'] = nil
end end
if multiple_databases if multiple_databases
ENV['MULTIPLE_DBS'] = "true" ENV['MULTIPLE_DBS'] = "true"
else else
ENV['MULTIPLE_DBS'] = nil ENV['MULTIPLE_DBS'] = nil
end end
self.output = `#{"jruby -S " if defined?(JRUBY_VERSION)}cucumber features/#{feature}.feature` self.output = `#{"jruby -S " if defined?(JRUBY_VERSION)}cucumber features/#{feature}.feature`

View File

@ -14,7 +14,7 @@ module DatabaseCleaner
self.strategy_db = desired_db self.strategy_db = desired_db
@db = desired_db @db = desired_db
end end
def strategy_db=(desired_db) def strategy_db=(desired_db)
if strategy.respond_to? :db= if strategy.respond_to? :db=
strategy.db = desired_db strategy.db = desired_db
@ -54,7 +54,7 @@ module DatabaseCleaner
end end
self.strategy_db = self.db self.strategy_db = self.db
@strategy @strategy
end end

View File

@ -56,7 +56,7 @@ module DatabaseCleaner
end end
@connections = temp @connections = temp
end end
def orm_module(symbol) def orm_module(symbol)
case symbol case symbol
when :active_record when :active_record

View File

@ -63,7 +63,7 @@ module DataMapper
end end
end end
class SqliteAdapter < DataObjectsAdapter class SqliteAdapter < DataObjectsAdapter
# taken from http://github.com/godfat/dm-mapping/tree/master # taken from http://github.com/godfat/dm-mapping/tree/master
def storage_names(repository = :default) def storage_names(repository = :default)

View File

@ -65,7 +65,7 @@ my_db:
YAML.should_receive(:load).and_return( {:nil => nil} ) YAML.should_receive(:load).and_return( {:nil => nil} )
subject.load_config subject.load_config
end end
it "should process erb in the config" do it "should process erb in the config" do
transformed = <<-Y transformed = <<-Y
my_db: my_db:

View File

@ -4,7 +4,7 @@ require 'database_cleaner/data_mapper/transaction'
module DatabaseCleaner module DatabaseCleaner
describe Base do describe Base do
describe "autodetect" do describe "autodetect" do
#Cache all ORMs, we'll need them later but not now. #Cache all ORMs, we'll need them later but not now.
@ -23,8 +23,8 @@ module DatabaseCleaner
Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper) Object.send(:remove_const, 'MongoMapper') if defined?(::MongoMapper)
Object.send(:remove_const, 'Mongoid') if defined?(::Mongoid) Object.send(:remove_const, 'Mongoid') if defined?(::Mongoid)
Object.send(:remove_const, 'CouchPotato') if defined?(::CouchPotato) Object.send(:remove_const, 'CouchPotato') if defined?(::CouchPotato)
# Restore ORMs # Restore ORMs
::ActiveRecord = Temp_AR if defined? Temp_AR ::ActiveRecord = Temp_AR if defined? Temp_AR
::DataMapper = Temp_DM if defined? Temp_DM ::DataMapper = Temp_DM if defined? Temp_DM
@ -77,7 +77,7 @@ module DatabaseCleaner
cleaner.orm.should == :mongo_mapper cleaner.orm.should == :mongo_mapper
cleaner.should be_auto_detected cleaner.should be_auto_detected
end end
it "should detect Mongoid fourth" do it "should detect Mongoid fourth" do
Object.const_set('Mongoid', 'Mongoid mock') Object.const_set('Mongoid', 'Mongoid mock')
Object.const_set('CouchPotato', 'Couching mock potatos') Object.const_set('CouchPotato', 'Couching mock potatos')
@ -85,7 +85,7 @@ module DatabaseCleaner
cleaner.orm.should == :mongoid cleaner.orm.should == :mongoid
cleaner.should be_auto_detected cleaner.should be_auto_detected
end end
it "should detect CouchPotato last" do it "should detect CouchPotato last" do
Object.const_set('CouchPotato', 'Couching mock potatos') Object.const_set('CouchPotato', 'Couching mock potatos')
@ -93,19 +93,19 @@ module DatabaseCleaner
cleaner.should be_auto_detected cleaner.should be_auto_detected
end end
end end
describe "orm_module" do describe "orm_module" do
it "should ask ::DatabaseCleaner what the module is for its orm" do it "should ask ::DatabaseCleaner what the module is for its orm" do
orm = mock("orm") orm = mock("orm")
mockule = mock("module") mockule = mock("module")
cleaner = ::DatabaseCleaner::Base.new cleaner = ::DatabaseCleaner::Base.new
cleaner.should_receive(:orm).and_return(orm) cleaner.should_receive(:orm).and_return(orm)
::DatabaseCleaner.should_receive(:orm_module).with(orm).and_return(mockule) ::DatabaseCleaner.should_receive(:orm_module).with(orm).and_return(mockule)
cleaner.send(:orm_module).should == mockule cleaner.send(:orm_module).should == mockule
end end
end end
describe "comparison" do describe "comparison" do
@ -126,12 +126,12 @@ module DatabaseCleaner
describe "initialization" do describe "initialization" do
context "db specified" do context "db specified" do
subject { ::DatabaseCleaner::Base.new(:active_record,:connection => :my_db) } subject { ::DatabaseCleaner::Base.new(:active_record,:connection => :my_db) }
it "should store db from :connection in params hash" do it "should store db from :connection in params hash" do
subject.db.should == :my_db subject.db.should == :my_db
end end
end end
describe "orm" do describe "orm" do
it "should store orm" do it "should store orm" do
cleaner = ::DatabaseCleaner::Base.new :a_orm cleaner = ::DatabaseCleaner::Base.new :a_orm
@ -150,30 +150,30 @@ module DatabaseCleaner
it "should default to autodetect upon initalisation" do it "should default to autodetect upon initalisation" do
subject.should be_auto_detected subject.should be_auto_detected
end end
end end
end end
describe "db" do describe "db" do
it "should default to :default" do it "should default to :default" do
subject.db.should == :default subject.db.should == :default
end end
it "should return any stored db value" do it "should return any stored db value" do
subject.stub(:strategy_db=) subject.stub(:strategy_db=)
subject.db = :test_db subject.db = :test_db
subject.db.should == :test_db subject.db.should == :test_db
end end
it "should pass db to any specified strategy" do it "should pass db to any specified strategy" do
subject.should_receive(:strategy_db=).with(:a_new_db) subject.should_receive(:strategy_db=).with(:a_new_db)
subject.db = :a_new_db subject.db = :a_new_db
end end
end end
describe "strategy_db=" do describe "strategy_db=" do
let(:strategy) { mock("strategy") } let(:strategy) { mock("strategy") }
before(:each) do before(:each) do
subject.strategy = strategy subject.strategy = strategy
end end
@ -183,16 +183,16 @@ module DatabaseCleaner
strategy.stub(:db=) strategy.stub(:db=)
subject.strategy_db = :a_db subject.strategy_db = :a_db
end end
context "when strategy supports db specification" do context "when strategy supports db specification" do
before(:each) { strategy.stub(:respond_to?).with(:db=).and_return true } before(:each) { strategy.stub(:respond_to?).with(:db=).and_return true }
it "should pass db to the strategy" do it "should pass db to the strategy" do
strategy.should_receive(:db=).with(:a_db) strategy.should_receive(:db=).with(:a_db)
subject.strategy_db = :a_db subject.strategy_db = :a_db
end end
end end
context "when strategy doesn't supports db specification" do context "when strategy doesn't supports db specification" do
before(:each) { strategy.stub(:respond_to?).with(:db=).and_return false } before(:each) { strategy.stub(:respond_to?).with(:db=).and_return false }
@ -202,7 +202,7 @@ module DatabaseCleaner
subject.strategy_db = db subject.strategy_db = db
end end
it "should raise an argument error when db isn't default" do it "should raise an argument error when db isn't default" do
db = mock("a db") db = mock("a db")
expect{ subject.strategy_db = db }.to raise_error ArgumentError expect{ subject.strategy_db = db }.to raise_error ArgumentError
@ -212,58 +212,58 @@ module DatabaseCleaner
describe "clean_with" do describe "clean_with" do
let (:strategy) { mock("strategy",:clean => true) } let (:strategy) { mock("strategy",:clean => true) }
before(:each) { subject.stub(:create_strategy).with(anything).and_return(strategy) } before(:each) { subject.stub(:create_strategy).with(anything).and_return(strategy) }
it "should pass all arguments to create_strategy" do it "should pass all arguments to create_strategy" do
subject.should_receive(:create_strategy).with(:lorum, :dollar, :amet, :ipsum => "random").and_return(strategy) subject.should_receive(:create_strategy).with(:lorum, :dollar, :amet, :ipsum => "random").and_return(strategy)
subject.clean_with :lorum, :dollar, :amet, { :ipsum => "random" } subject.clean_with :lorum, :dollar, :amet, { :ipsum => "random" }
end end
it "should invoke clean on the created strategy" do it "should invoke clean on the created strategy" do
strategy.should_receive(:clean) strategy.should_receive(:clean)
subject.clean_with :strategy subject.clean_with :strategy
end end
it "should return the strategy" do it "should return the strategy" do
subject.clean_with( :strategy ).should == strategy subject.clean_with( :strategy ).should == strategy
end end
end end
describe "clean_with!" do describe "clean_with!" do
let (:strategy) { mock("strategy",:clean => true) } let (:strategy) { mock("strategy",:clean => true) }
before(:each) { subject.stub(:create_strategy).with(anything).and_return(strategy) } before(:each) { subject.stub(:create_strategy).with(anything).and_return(strategy) }
it "should pass all arguments to create_strategy" do it "should pass all arguments to create_strategy" do
subject.should_receive(:create_strategy).with(:lorum, :dollar, :amet, :ipsum => "random").and_return(strategy) subject.should_receive(:create_strategy).with(:lorum, :dollar, :amet, :ipsum => "random").and_return(strategy)
subject.clean_with! :lorum, :dollar, :amet, { :ipsum => "random" } subject.clean_with! :lorum, :dollar, :amet, { :ipsum => "random" }
end end
it "should invoke clean on the created strategy" do it "should invoke clean on the created strategy" do
strategy.should_receive(:clean) strategy.should_receive(:clean)
subject.clean_with! :strategy subject.clean_with! :strategy
end end
it "should return the strategy" do it "should return the strategy" do
subject.clean_with!( :strategy ).should == strategy subject.clean_with!( :strategy ).should == strategy
end end
end end
describe "create_strategy" do describe "create_strategy" do
let(:klass) { mock("klass",:new => mock("instance")) } let(:klass) { mock("klass",:new => mock("instance")) }
before :each do before :each do
subject.stub(:orm_strategy).and_return(klass) subject.stub(:orm_strategy).and_return(klass)
end end
it "should pass the first argument to orm_strategy" do it "should pass the first argument to orm_strategy" do
subject.should_receive(:orm_strategy).with(:strategy).and_return(Object) subject.should_receive(:orm_strategy).with(:strategy).and_return(Object)
subject.create_strategy :strategy subject.create_strategy :strategy
end end
it "should pass the remainding argument to orm_strategy.new" do it "should pass the remainding argument to orm_strategy.new" do
klass.should_receive(:new).with(:params => {:lorum => "ipsum"}) klass.should_receive(:new).with(:params => {:lorum => "ipsum"})
subject.create_strategy :strategy, {:params => {:lorum => "ipsum"}} subject.create_strategy :strategy, {:params => {:lorum => "ipsum"}}
end end
it "should return the resulting strategy" do it "should return the resulting strategy" do
@ -273,31 +273,31 @@ module DatabaseCleaner
describe "strategy=" do describe "strategy=" do
let(:mock_strategy) { mock("strategy") } let(:mock_strategy) { mock("strategy") }
it "should proxy symbolised strategies to create_strategy" do it "should proxy symbolised strategies to create_strategy" do
subject.should_receive(:create_strategy).with(:symbol) subject.should_receive(:create_strategy).with(:symbol)
subject.strategy = :symbol subject.strategy = :symbol
end end
it "should proxy params with symbolised strategies" do it "should proxy params with symbolised strategies" do
subject.should_receive(:create_strategy).with(:symbol,:param => "one") subject.should_receive(:create_strategy).with(:symbol,:param => "one")
subject.strategy= :symbol, {:param => "one"} subject.strategy= :symbol, {:param => "one"}
end end
it "should accept strategy objects" do it "should accept strategy objects" do
expect{ subject.strategy = mock_strategy }.to_not raise_error expect{ subject.strategy = mock_strategy }.to_not raise_error
end end
it "should raise argument error when params given with strategy Object" do it "should raise argument error when params given with strategy Object" do
expect{ subject.strategy = mock("object"), {:param => "one"} }.to raise_error ArgumentError expect{ subject.strategy = mock("object"), {:param => "one"} }.to raise_error ArgumentError
end end
it "should attempt to set strategy db" do it "should attempt to set strategy db" do
subject.stub(:db).and_return(:my_db) subject.stub(:db).and_return(:my_db)
subject.should_receive(:strategy_db=).with(:my_db) subject.should_receive(:strategy_db=).with(:my_db)
subject.strategy = mock_strategy subject.strategy = mock_strategy
end end
it "should return the stored strategy" do it "should return the stored strategy" do
result = subject.strategy = mock_strategy result = subject.strategy = mock_strategy
result.should == mock_strategy result.should == mock_strategy
@ -309,14 +309,14 @@ module DatabaseCleaner
subject.instance_values["@strategy"] = nil subject.instance_values["@strategy"] = nil
expect{ subject.strategy }.to raise_error NoStrategySetError expect{ subject.strategy }.to raise_error NoStrategySetError
end end
it "should return @strategy if @strategy is present" do it "should return @strategy if @strategy is present" do
strategum = mock("strategy") strategum = mock("strategy")
subject.strategy = strategum subject.strategy = strategum
subject.strategy.should == strategum subject.strategy.should == strategum
end end
end end
describe "orm=" do describe "orm=" do
it "should stored the desired orm" do it "should stored the desired orm" do
subject.orm.should_not == :desired_orm subject.orm.should_not == :desired_orm
@ -327,12 +327,12 @@ module DatabaseCleaner
describe "orm" do describe "orm" do
let(:mock_orm) { mock("orm") } let(:mock_orm) { mock("orm") }
it "should return orm if orm set" do it "should return orm if orm set" do
subject.instance_variable_set "@orm", mock_orm subject.instance_variable_set "@orm", mock_orm
subject.orm.should == mock_orm subject.orm.should == mock_orm
end end
context "orm isn't set" do context "orm isn't set" do
before(:each) { subject.instance_variable_set "@orm", nil } before(:each) { subject.instance_variable_set "@orm", nil }
@ -350,25 +350,25 @@ module DatabaseCleaner
describe "proxy methods" do describe "proxy methods" do
let (:strategy) { mock("strategy") } let (:strategy) { mock("strategy") }
before(:each) do before(:each) do
subject.stub(:strategy).and_return(strategy) subject.stub(:strategy).and_return(strategy)
end end
describe "start" do describe "start" do
it "should proxy start to the strategy" do it "should proxy start to the strategy" do
strategy.should_receive(:start) strategy.should_receive(:start)
subject.start subject.start
end end
end end
describe "clean" do describe "clean" do
it "should proxy clean to the strategy" do it "should proxy clean to the strategy" do
strategy.should_receive(:clean) strategy.should_receive(:clean)
subject.clean subject.clean
end end
end end
describe "clean!" do describe "clean!" do
it "should proxy clean! to the strategy clean" do it "should proxy clean! to the strategy clean" do
strategy.should_receive(:clean) strategy.should_receive(:clean)
@ -376,66 +376,66 @@ module DatabaseCleaner
end end
end end
end end
describe "auto_detected?" do describe "auto_detected?" do
it "should return true unless @autodetected is nil" do it "should return true unless @autodetected is nil" do
subject.instance_variable_set("@autodetected","not nil") subject.instance_variable_set("@autodetected","not nil")
subject.auto_detected?.should be_true subject.auto_detected?.should be_true
end end
it "should return false if @autodetect is nil" do it "should return false if @autodetect is nil" do
subject.instance_variable_set("@autodetected",nil) subject.instance_variable_set("@autodetected",nil)
subject.auto_detected?.should be_false subject.auto_detected?.should be_false
end end
end end
describe "orm_strategy" do describe "orm_strategy" do
let (:klass) { mock("klass") } let (:klass) { mock("klass") }
before(:each) do before(:each) do
subject.stub(:orm_module).and_return(klass) subject.stub(:orm_module).and_return(klass)
end end
context "in response to a LoadError" do context "in response to a LoadError" do
before(:each) { subject.should_receive(:require).with(anything).and_raise(LoadError) } before(:each) { subject.should_receive(:require).with(anything).and_raise(LoadError) }
it "should catch LoadErrors" do it "should catch LoadErrors" do
expect { subject.send(:orm_strategy,:a_strategy) }.to_not raise_error LoadError expect { subject.send(:orm_strategy,:a_strategy) }.to_not raise_error LoadError
end end
it "should raise UnknownStrategySpecified" do it "should raise UnknownStrategySpecified" do
expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified
end end
it "should ask orm_module if it will list available_strategies" do it "should ask orm_module if it will list available_strategies" do
klass.should_receive(:respond_to?).with(:available_strategies) klass.should_receive(:respond_to?).with(:available_strategies)
subject.stub(:orm_module).and_return(klass) subject.stub(:orm_module).and_return(klass)
expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified
end end
it "should use available_strategies (for the error message) if its available" do it "should use available_strategies (for the error message) if its available" do
klass.stub(:respond_to?).with(:available_strategies).and_return(true) klass.stub(:respond_to?).with(:available_strategies).and_return(true)
klass.should_receive(:available_strategies).and_return([]) klass.should_receive(:available_strategies).and_return([])
subject.stub(:orm_module).and_return(klass) subject.stub(:orm_module).and_return(klass)
expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified expect { subject.send(:orm_strategy,:a_strategy) }.to raise_error UnknownStrategySpecified
end end
end end
it "should return the constant of the Strategy class requested" do it "should return the constant of the Strategy class requested" do
strategy_klass = mock("strategy klass") strategy_klass = mock("strategy klass")
subject.stub(:require).with(anything).and_return(true) subject.stub(:require).with(anything).and_return(true)
klass.should_receive(:const_get).with("Cunningplan").and_return(strategy_klass) klass.should_receive(:const_get).with("Cunningplan").and_return(strategy_klass)
subject.send(:orm_strategy, :cunningplan).should == strategy_klass subject.send(:orm_strategy, :cunningplan).should == strategy_klass
end end
end end
end end
end end

View File

@ -48,7 +48,7 @@ describe ::DatabaseCleaner do
::DatabaseCleaner.connections.size.should == 1 ::DatabaseCleaner.connections.size.should == 1
end end
end end
it "should accept multiple orm's" do it "should accept multiple orm's" do
::DatabaseCleaner[:couch_potato] ::DatabaseCleaner[:couch_potato]
::DatabaseCleaner[:data_mapper] ::DatabaseCleaner[:data_mapper]
@ -64,7 +64,7 @@ describe ::DatabaseCleaner do
cleaner.orm.should == :active_record cleaner.orm.should == :active_record
cleaner.db.should == :first_connection cleaner.db.should == :first_connection
end end
it "should accept multiple connections for a single orm" do it "should accept multiple connections for a single orm" do
::DatabaseCleaner[:data_mapper,{:connection => :first_db}] ::DatabaseCleaner[:data_mapper,{:connection => :first_db}]
::DatabaseCleaner[:data_mapper,{:connection => :second_db}] ::DatabaseCleaner[:data_mapper,{:connection => :second_db}]
@ -74,7 +74,7 @@ describe ::DatabaseCleaner do
::DatabaseCleaner.connections[1].orm.should == :data_mapper ::DatabaseCleaner.connections[1].orm.should == :data_mapper
::DatabaseCleaner.connections[1].db.should == :second_db ::DatabaseCleaner.connections[1].db.should == :second_db
end end
it "should accept multiple connections and multiple orms" do it "should accept multiple connections and multiple orms" do
::DatabaseCleaner[:data_mapper, {:connection => :first_db} ] ::DatabaseCleaner[:data_mapper, {:connection => :first_db} ]
::DatabaseCleaner[:active_record,{:connection => :second_db}] ::DatabaseCleaner[:active_record,{:connection => :second_db}]
@ -238,7 +238,7 @@ describe ::DatabaseCleaner do
it "should remove duplicates if they are identical" do it "should remove duplicates if they are identical" do
orm = mock("orm") orm = mock("orm")
connection = mock("a datamapper connection", :orm => orm ) connection = mock("a datamapper connection", :orm => orm )
::DatabaseCleaner.connections_stub! [connection,connection,connection] ::DatabaseCleaner.connections_stub! [connection,connection,connection]
::DatabaseCleaner.remove_duplicates ::DatabaseCleaner.remove_duplicates
@ -256,39 +256,39 @@ describe ::DatabaseCleaner do
DatabaseCleaner.app_root.should == '/path/to' DatabaseCleaner.app_root.should == '/path/to'
end end
end end
describe "orm_module" do describe "orm_module" do
subject { ::DatabaseCleaner } subject { ::DatabaseCleaner }
it "should return DatabaseCleaner::ActiveRecord for :active_record" do it "should return DatabaseCleaner::ActiveRecord for :active_record" do
::DatabaseCleaner::ActiveRecord = mock("ar module") unless defined? ::DatabaseCleaner::ActiveRecord ::DatabaseCleaner::ActiveRecord = mock("ar module") unless defined? ::DatabaseCleaner::ActiveRecord
subject.orm_module(:active_record).should == DatabaseCleaner::ActiveRecord subject.orm_module(:active_record).should == DatabaseCleaner::ActiveRecord
end end
it "should return DatabaseCleaner::DataMapper for :data_mapper" do it "should return DatabaseCleaner::DataMapper for :data_mapper" do
::DatabaseCleaner::DataMapper = mock("dm module") unless defined? ::DatabaseCleaner::DataMapper ::DatabaseCleaner::DataMapper = mock("dm module") unless defined? ::DatabaseCleaner::DataMapper
subject.orm_module(:data_mapper).should == DatabaseCleaner::DataMapper subject.orm_module(:data_mapper).should == DatabaseCleaner::DataMapper
end end
it "should return DatabaseCleaner::MongoMapper for :mongo_mapper" do it "should return DatabaseCleaner::MongoMapper for :mongo_mapper" do
::DatabaseCleaner::MongoMapper = mock("mm module") unless defined? ::DatabaseCleaner::MongoMapper ::DatabaseCleaner::MongoMapper = mock("mm module") unless defined? ::DatabaseCleaner::MongoMapper
subject.orm_module(:mongo_mapper).should == DatabaseCleaner::MongoMapper subject.orm_module(:mongo_mapper).should == DatabaseCleaner::MongoMapper
end end
it "should return DatabaseCleaner::Mongoid for :mongoid" do it "should return DatabaseCleaner::Mongoid for :mongoid" do
::DatabaseCleaner::Mongoid = mock("mongoid module") unless defined? ::DatabaseCleaner::Mongoid ::DatabaseCleaner::Mongoid = mock("mongoid module") unless defined? ::DatabaseCleaner::Mongoid
subject.orm_module(:mongoid).should == DatabaseCleaner::Mongoid subject.orm_module(:mongoid).should == DatabaseCleaner::Mongoid
end end
it "should return DatabaseCleaner::Mongo for :mongo" do it "should return DatabaseCleaner::Mongo for :mongo" do
::DatabaseCleaner::Mongo = mock("mongo module") unless defined? ::DatabaseCleaner::Mongo ::DatabaseCleaner::Mongo = mock("mongo module") unless defined? ::DatabaseCleaner::Mongo
subject.orm_module(:mongo).should == DatabaseCleaner::Mongo subject.orm_module(:mongo).should == DatabaseCleaner::Mongo
end end
it "should return DatabaseCleaner::CouchPotato for :couch_potato" do it "should return DatabaseCleaner::CouchPotato for :couch_potato" do
::DatabaseCleaner::CouchPotato = mock("cp module") unless defined? ::DatabaseCleaner::CouchPotato ::DatabaseCleaner::CouchPotato = mock("cp module") unless defined? ::DatabaseCleaner::CouchPotato
subject.orm_module(:couch_potato).should == DatabaseCleaner::CouchPotato subject.orm_module(:couch_potato).should == DatabaseCleaner::CouchPotato
end end
end end
end end

View File

@ -30,7 +30,7 @@ module DatabaseCleaner
end end
def ensure_counts(expected_counts) def ensure_counts(expected_counts)
# I had to add this sanity_check garbage because I was getting non-determinisc results from mongomapper at times.. # I had to add this sanity_check garbage because I was getting non-determinisc results from mongomapper at times..
# very odd and disconcerting... # very odd and disconcerting...
sanity_check = expected_counts.delete(:sanity_check) sanity_check = expected_counts.delete(:sanity_check)
begin begin

View File

@ -13,7 +13,7 @@ require 'database_cleaner'
Spec::Runner.configure do |config| Spec::Runner.configure do |config|
end end
alias running lambda alias running lambda