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|
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__)}/../.."
orm_sym = orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym

View File

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

View File

@ -13,21 +13,21 @@ class FeatureRunner
def go(feature)
full_dir ||= File.expand_path(File.dirname(__FILE__) + "/../../examples/")
Dir.chdir(full_dir) do
ENV['ORM'] = orm
ENV['STRATEGY'] = strategy
if another_orm
ENV['ANOTHER_ORM'] = another_orm
else
ENV['ANOTHER_ORM'] = nil
end
if multiple_databases
ENV['MULTIPLE_DBS'] = "true"
else
ENV['MULTIPLE_DBS'] = nil
ENV['MULTIPLE_DBS'] = nil
end
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
@db = desired_db
end
def strategy_db=(desired_db)
if strategy.respond_to? :db=
strategy.db = desired_db
@ -54,7 +54,7 @@ module DatabaseCleaner
end
self.strategy_db = self.db
@strategy
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ module DatabaseCleaner
end
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...
sanity_check = expected_counts.delete(:sanity_check)
begin

View File

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