Skip to content

Commit

Permalink
Improve shared_examples
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSmartnik authored and botandrose committed Mar 5, 2020
1 parent a62840d commit 64e3945
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/database_cleaner/spec/shared_examples.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
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(: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(:db=) }
it { is_expected.to respond_to(:start) }
it { is_expected.to respond_to(:clean) }
it { is_expected.to respond_to(:cleaning) }
Expand All @@ -21,4 +13,12 @@
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

0 comments on commit 64e3945

Please sign in to comment.