diff --git a/lib/database_cleaner/configuration.rb b/lib/database_cleaner/configuration.rb index a5fe361..a9dca75 100644 --- a/lib/database_cleaner/configuration.rb +++ b/lib/database_cleaner/configuration.rb @@ -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 diff --git a/spec/database_cleaner/configuration_spec.rb b/spec/database_cleaner/configuration_spec.rb index c195648..df3f7ca 100644 --- a/spec/database_cleaner/configuration_spec.rb +++ b/spec/database_cleaner/configuration_spec.rb @@ -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