Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared example for database_cleaner adapter #629

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions lib/database_cleaner/spec/shared_examples.rb
Original file line number Diff line number Diff line change
@@ -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