Skip to content

Instantly share code, notes, and snippets.

@plainprogrammer
Created December 1, 2017 21:11
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 plainprogrammer/4390585607fbcc070c06bb084b855cdb to your computer and use it in GitHub Desktop.
Save plainprogrammer/4390585607fbcc070c06bb084b855cdb to your computer and use it in GitHub Desktop.
Applying Clean Architecture: Repository Interfaces
RSpec.shared_examples "Business Profiles Repository Interface" do
describe "instance methods" do
it { is_expected.to respond_to :find }
it { is_expected.to respond_to :update }
end
describe "#find" do
let(:invalid_result) { subject.find invalid_id }
it "return a Nav::Entities::BusinessProfile" do
expect(subject.find valid_id).to be_a(Nav::Entities::BusinessProfile)
expect(subject.find invalid_id).to be_a(Nav::Entities::BusinessProfile)
end
it "adds error message when unsuccessful" do
expect(invalid_result.errors).to include("can not find Business Profile with ID #{invalid_id}")
end
end
describe "#update" do
it "return a Nav::Entities::BusinessProfile" do
expect(subject.update for_id: valid_id).to be_a(Nav::Entities::BusinessProfile)
expect(subject.update for_id: invalid_id).to be_a(Nav::Entities::BusinessProfile)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment