mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
configuration change
This commit is contained in:
parent
55bc444994
commit
27e8b337f7
2 changed files with 13 additions and 8 deletions
|
@ -6,9 +6,14 @@ module DatabaseCleaner
|
||||||
|
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
def self.available_strategies
|
def self.available_strategies
|
||||||
['truncation', 'transaction']
|
%w[truncation transaction]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module DataMapper
|
||||||
|
def self.available_strategies
|
||||||
|
%w[]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
@ -17,14 +22,10 @@ module DatabaseCleaner
|
||||||
if strategy.is_a?(Symbol)
|
if strategy.is_a?(Symbol)
|
||||||
@strategy = orm_strategy(strategy).new(*strategy_args)
|
@strategy = orm_strategy(strategy).new(*strategy_args)
|
||||||
else
|
else
|
||||||
raise UnknownStrategySpecified, "need good error message"
|
@strategy = strategy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_strategy
|
|
||||||
@strategy = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def start
|
def start
|
||||||
strategy.start
|
strategy.start
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe DatabaseCleaner do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
DatabaseCleaner::ActiveRecord::Transaction.stub!(:new).and_return(@strategy = mock('strategy'))
|
DatabaseCleaner::ActiveRecord::Transaction.stub!(:new).and_return(@strategy = mock('strategy'))
|
||||||
Object.const_set('ActiveRecord', "just mocking out the constant here...") unless defined?(::ActiveRecord)
|
Object.const_set('ActiveRecord', "just mocking out the constant here...") unless defined?(::ActiveRecord)
|
||||||
DatabaseCleaner.clear_strategy
|
DatabaseCleaner.strategy = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".strategy=" do
|
describe ".strategy=" do
|
||||||
|
@ -30,7 +30,11 @@ describe DatabaseCleaner do
|
||||||
|
|
||||||
it "should raise an error when the specified strategy is not found" 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 = :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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue