Last active
July 2, 2018 21:38
-
-
Save chelseatroy/76bea8a5e2dbe383277052df77804328 to your computer and use it in GitHub Desktop.
Switching Data Sources: Testing Data Equivalence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe ReceiptDataSourceEquivalence do | |
before(:suite) do | |
@repository_receipt_data_source ||= Repositories::ReceiptDataSource.new(environment: Rails.env) | |
@service_receipt_data_source ||= Services::ReceiptDataSource.new(environment: Rails.env) | |
@local_records = @repository_receipt_data_source.all.collect(&:id) | |
@api_records = @service_receipt_data_source.all.collect(&:id) | |
@on_records = Array(@local_records & @api_records) | |
end | |
describe "receipts list call" do | |
it "provides receipts with the same set of ids, each of which have equivalent numbers" do | |
expect(Set.new(local_records)).to eq(Set.new(api_records)) | |
end | |
end | |
describe "receipts detail call" do | |
it "given an id, provides a receipt with the same attributes from local database or API" | |
@on_records.each do |id| | |
local_record = @repository_receipt_data_source.get(id) | |
api_record = @service_receipt_data_source.get(id) | |
expect local_record.number.to eq(api_record.number) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment