|
82 | 82 | end
|
83 | 83 | end
|
84 | 84 |
|
| 85 | + context "when the expected interaction is executed but is marked to not be written to the pact file" do |
| 86 | + let(:zebra_interaction) do |
| 87 | + { |
| 88 | + description: "a request for zebras", |
| 89 | + provider_state: "zebras exist", |
| 90 | + request: { |
| 91 | + method: :get, |
| 92 | + path: '/zebras', |
| 93 | + headers: {'Accept' => 'application/zebra'} |
| 94 | + }, |
| 95 | + response: { |
| 96 | + status: 200 |
| 97 | + }, |
| 98 | + metadata: { |
| 99 | + write_to_pact: false |
| 100 | + } |
| 101 | + }.to_json |
| 102 | + end |
| 103 | + |
| 104 | + before do |
| 105 | + post "/interactions", zebra_interaction, admin_headers |
| 106 | + end |
| 107 | + |
| 108 | + it "does not include the interaction in the pact file" do |
| 109 | + get "/alligators", nil, {'HTTP_ACCEPT' => 'application/alligator'} |
| 110 | + get "/giraffes", nil, {'HTTP_ACCEPT' => 'application/giraffe'} |
| 111 | + get "/zebras", nil, {'HTTP_ACCEPT' => 'application/zebra'} |
| 112 | + post "/pact", pact_details, admin_headers |
| 113 | + |
| 114 | + expect(pact_json['interactions']).to include( |
| 115 | + include("description" => "a request for alligators") |
| 116 | + ) |
| 117 | + expect(pact_json['interactions']).to include( |
| 118 | + include("description" => "a request for giraffes") |
| 119 | + ) |
| 120 | + expect(pact_json['interactions']).to_not include( |
| 121 | + include("description" => "a request for zebras") |
| 122 | + ) |
| 123 | + end |
| 124 | + end |
| 125 | + |
85 | 126 | context "when no interactions are executed" do
|
86 | 127 | it "does not create the pact file" do
|
87 | 128 | post "/pact", pact_details, admin_headers
|
|
0 commit comments