Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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