From 64e39458617c09a45fe0dc4e8c1f0785921808a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0TheSmartnik?= Date: Fri, 6 Mar 2020 01:09:38 +0300 Subject: [PATCH] Improve shared_examples --- lib/database_cleaner/spec/shared_examples.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/database_cleaner/spec/shared_examples.rb b/lib/database_cleaner/spec/shared_examples.rb index 18e28bdd..aef57513 100644 --- a/lib/database_cleaner/spec/shared_examples.rb +++ b/lib/database_cleaner/spec/shared_examples.rb @@ -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) } @@ -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