configuration change

This commit is contained in:
Ben Mabey 2009-03-04 13:33:58 -07:00
parent 55bc444994
commit 27e8b337f7
2 changed files with 13 additions and 8 deletions

View file

@ -6,9 +6,14 @@ module DatabaseCleaner
module ActiveRecord
def self.available_strategies
['truncation', 'transaction']
%w[truncation transaction]
end
end
module DataMapper
def self.available_strategies
%w[]
end
end
class << self
@ -17,14 +22,10 @@ module DatabaseCleaner
if strategy.is_a?(Symbol)
@strategy = orm_strategy(strategy).new(*strategy_args)
else
raise UnknownStrategySpecified, "need good error message"
@strategy = strategy
end
end
def clear_strategy
@strategy = nil
end
def start
strategy.start
end

View file

@ -6,7 +6,7 @@ describe DatabaseCleaner do
before(:each) do
DatabaseCleaner::ActiveRecord::Transaction.stub!(:new).and_return(@strategy = mock('strategy'))
Object.const_set('ActiveRecord', "just mocking out the constant here...") unless defined?(::ActiveRecord)
DatabaseCleaner.clear_strategy
DatabaseCleaner.strategy = nil
end
describe ".strategy=" do
@ -30,7 +30,11 @@ describe DatabaseCleaner do
it "should raise an error when the specified strategy is not found" do
running { DatabaseCleaner.strategy = :foo }.should raise_error(DatabaseCleaner::UnknownStrategySpecified)
running { DatabaseCleaner.strategy = Array }.should raise_error(DatabaseCleaner::UnknownStrategySpecified)
end
it "should allow any object to be set as the strategy" do
mock_strategy = mock('strategy')
running { DatabaseCleaner.strategy = mock_strategy }.should_not raise_error
end
end