diff --git a/spec/database_cleaner/active_record/base_spec.rb b/spec/database_cleaner/active_record/base_spec.rb index 6e24775..061c659 100644 --- a/spec/database_cleaner/active_record/base_spec.rb +++ b/spec/database_cleaner/active_record/base_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +require 'active_record' require 'database_cleaner/active_record/base' require 'database_cleaner/shared_strategy_spec' @@ -13,7 +14,7 @@ module DatabaseCleaner end describe ExampleStrategy do - it_should_behave_like "database cleaner strategy" + it_should_behave_like "a generic strategy" it { expect{ subject.connection_klass }.to_not raise_error } end end diff --git a/spec/database_cleaner/couch_potato/truncation_spec.rb b/spec/database_cleaner/couch_potato/truncation_spec.rb index 6771c13..c4e3d34 100644 --- a/spec/database_cleaner/couch_potato/truncation_spec.rb +++ b/spec/database_cleaner/couch_potato/truncation_spec.rb @@ -1,23 +1,14 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'database_cleaner/couch_potato/truncation' +require 'couch_potato' module DatabaseCleaner module CouchPotato describe Truncation do - - #doing the require in the file root breaks autospec, doing it before(:all) just fails the specs - before(:all) do - #pend the specs if CouchPotato is missing - if defined?(::CouchPotato) - require 'couch_potato' - end - end - let (:database) { mock('database') } + before(:each) do - #pend the specs if CouchPotato is missing - pending "Please install couchdb and couch_potato before running these specs" unless defined?(::CouchPotato) ::CouchPotato.stub!(:couchrest_database).and_return(database) end diff --git a/spec/database_cleaner/generic/base_spec.rb b/spec/database_cleaner/generic/base_spec.rb index 714fbcc..fa291a6 100644 --- a/spec/database_cleaner/generic/base_spec.rb +++ b/spec/database_cleaner/generic/base_spec.rb @@ -13,9 +13,7 @@ module ::DatabaseCleaner its (:available_strategies) { should be_empty } end - it { should respond_to :db } - it { should respond_to :db= } - it { should respond_to :connection_klass } + it_should_behave_like "a generic strategy" its (:db) { should == :default } diff --git a/spec/database_cleaner/mongo_mapper/truncation_spec.rb b/spec/database_cleaner/mongo_mapper/truncation_spec.rb index 1354eb9..b4f2375 100644 --- a/spec/database_cleaner/mongo_mapper/truncation_spec.rb +++ b/spec/database_cleaner/mongo_mapper/truncation_spec.rb @@ -1,5 +1,7 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'database_cleaner/mongo_mapper/truncation' +require 'mongo_mapper' +require File.dirname(__FILE__) + '/mongo_examples' module DatabaseCleaner module MongoMapper @@ -8,20 +10,12 @@ module DatabaseCleaner #doing this in the file root breaks autospec, doing it before(:all) just fails the specs before(:all) do - #pend the specs if MongoMapper is missing - if defined?(::MongoMapper) && defined?(::Mongo) - require 'mongo_mapper' - require File.dirname(__FILE__) + '/mongo_examples' - ::MongoMapper.connection = ::Mongo::Connection.new('127.0.0.1') @test_db = 'database_cleaner_specs' ::MongoMapper.database = @test_db - end end before(:each) do - #make these specs pend if orm not installed - pending "Please install MongoMapper + Mongo to run these specs" unless defined?(::MongoMapper) && defined?(::Mongo) ::MongoMapper.connection.drop_database(@test_db) end diff --git a/spec/database_cleaner/shared_strategy_spec.rb b/spec/database_cleaner/shared_strategy_spec.rb index 3603c53..4147bb6 100644 --- a/spec/database_cleaner/shared_strategy_spec.rb +++ b/spec/database_cleaner/shared_strategy_spec.rb @@ -1,5 +1,15 @@ -shared_examples_for "database cleaner strategy" do +shared_examples_for "a generic strategy" do it { should respond_to :db } it { should respond_to :db= } it { should respond_to :connection_klass } +end + +shared_examples_for "a generic truncation strategy" do + it { should respond_to :start } + it { should respond_to :clean } +end + +shared_examples_for "a generic transaction strategy" do + it { should respond_to :start } + it { should respond_to :clean } end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f6884a1..6d496f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,12 +1,12 @@ require 'rubygems' require 'spec' -require 'active_record' +#require 'active_record' #require 'mongo_mapper' $:.unshift(File.dirname(__FILE__) + '/../lib') require 'database_cleaner' Spec::Runner.configure do |config| - + end alias running lambda