diff --git a/lib/database_cleaner/spec/shared_examples.rb b/lib/database_cleaner/spec/shared_examples.rb index a8a4ed3c..aef57513 100644 --- a/lib/database_cleaner/spec/shared_examples.rb +++ b/lib/database_cleaner/spec/shared_examples.rb @@ -1,15 +1,24 @@ -RSpec.shared_examples_for "a generic strategy" do +RSpec.shared_examples_for "a database_cleaner strategy" do it { is_expected.to respond_to(:db) } -end - -RSpec.shared_examples_for "a generic truncation strategy" do + it { is_expected.to respond_to(:db=) } it { is_expected.to respond_to(:start) } it { is_expected.to respond_to(:clean) } it { is_expected.to respond_to(:cleaning) } end -RSpec.shared_examples_for "a generic transaction strategy" do - it { is_expected.to respond_to(:start) } - it { is_expected.to respond_to(:clean) } - it { is_expected.to respond_to(:cleaning) } +RSpec.shared_examples_for "a database_cleaner adapter" do + it { expect(described_class).to respond_to(:available_strategies) } + it { expect(described_class).to respond_to(:default_strategy) } + + it 'default_strategy should be part of available_strategies' do + expect(described_class.available_strategies).to include(described_class.default_strategy) + end + + describe 'all strategies should adhere to a database_cleaner strategy interface' do + described_class.available_strategies.each do |strategy| + subject { described_class.const_get(strategy.to_s.capitalize).new } + + it_behaves_like 'a database_cleaner strategy' + end + end end