-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for ProviderPactsDecorator
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'pact_broker/api/decorators/provider_pacts_decorator' | ||
|
||
module PactBroker | ||
module Api | ||
module Decorators | ||
describe ProviderPactsDecorator do | ||
|
||
let(:pacts) { [pact]} | ||
let(:pact) do | ||
double('pact', name: 'Pact name', consumer_name: 'Foo') | ||
end | ||
let(:user_options) do | ||
{ | ||
base_url: 'http://example.org', | ||
resource_url: 'http://example.org/provider-pacts', | ||
title: 'title' | ||
} | ||
end | ||
|
||
before do | ||
allow_any_instance_of(ProviderPactsDecorator).to receive(:pact_url).and_return('pact_url') | ||
end | ||
|
||
subject { JSON.parse ProviderPactsDecorator.new(pacts).to_json(user_options: user_options), symbolize_names: true } | ||
|
||
let(:expected) do | ||
{ | ||
:_links => { | ||
:self=> { | ||
:href=> "http://example.org/provider-pacts", | ||
:title => "title" | ||
}, | ||
:provider => { | ||
:href => "http://example.org/pacticipants/", | ||
:title => nil | ||
}, | ||
:"pb:pacts" =>[{ | ||
:href => "pact_url", | ||
:title => "Pact name", | ||
:name => "Foo" }], | ||
:pacts => [{ | ||
:href => "pact_url", | ||
:title => "DEPRECATED - please use the pb:pacts relation", | ||
:name => "Foo" | ||
} | ||
] | ||
} | ||
} | ||
end | ||
|
||
it "matches the expected JSON" do | ||
expect(subject).to match_pact(expected) | ||
end | ||
end | ||
end | ||
end | ||
end |