Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created June 3, 2018 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/03806e80f0d5342bc2af6a9e0c322328 to your computer and use it in GitHub Desktop.
Save chelseatroy/03806e80f0d5342bc2af6a9e0c322328 to your computer and use it in GitHub Desktop.
Switching Data Sources: Repository Unit Test
require 'rails_helper'
RSpec.describe Repositories::ReceiptDataSource do
describe "get_receipts" do
before do
Receipt.delete_all
end
it "gets all receipts" do
@subject_under_test = Repositories::ReceiptDataSource.new
FactoryGirl.create(:receipt)
FactoryGirl.create(:receipt)
#This is an example, but you could do any number and combination of assertions here
expect(@subject_under_test.get_receipts.length).to eq(2)
expect(@subject_under_test.get_receipts.first).to be_instance_of(Receipt)
end
...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment