Commit b52af92c authored by Mike Kozono's avatar Mike Kozono

Add shared examples to snippet replicator

parent 246fbade
......@@ -19,6 +19,7 @@ RSpec.shared_examples 'a repository replicator' do
end
it_behaves_like 'a replicator'
it_behaves_like 'a verifiable replicator'
# This could be included in each model's spec, but including it here is DRYer.
include_examples 'a replicable model'
......
......@@ -49,18 +49,20 @@ RSpec.shared_examples 'a verifiable replicator' do
end
describe '#calculate_checksum!' do
it 'calculates the checksum' do
before do
model_record.save!
end
it 'calculates the checksum' do
expect(model_record).to receive(:calculate_checksum!).and_return('abc123')
replicator.calculate_checksum!
expect(model_record.reload.verification_checksum).not_to be_nil
expect(model_record.reload.verified_at).not_to be_nil
expect(model_record.reload.verification_checksum).to eq('abc123')
expect(model_record.verified_at).not_to be_nil
end
it 'saves the error message and increments retry counter' do
model_record.save!
allow(model_record).to receive(:calculate_checksum!) do
raise StandardError.new('Failure to calculate checksum')
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment