pact 1.3.3 → 1.4.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +16 -1
- data/Gemfile +5 -0
- data/Gemfile.lock +34 -13
- data/README.md +3 -2
- data/example/animal-service/lib/animal_service/api.rb +1 -0
- data/example/zoo-app/lib/zoo_app/animal_service_client.rb +0 -9
- data/example/zoo-app/lib/zoo_app/models/alligator.rb +2 -0
- data/lib/pact.rb +6 -5
- data/lib/pact/cli.rb +0 -26
- data/lib/pact/consumer/configuration.rb +0 -1
- data/lib/pact/consumer/configuration/configuration_extensions.rb +51 -0
- data/lib/pact/consumer/consumer_contract_builder.rb +1 -2
- data/lib/pact/consumer/interaction_builder.rb +2 -4
- data/lib/pact/doc/interaction_view_model.rb +9 -6
- data/lib/pact/doc/sort_interactions.rb +1 -1
- data/lib/pact/provider/rspec.rb +11 -9
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +5 -0
- data/spec/lib/pact/consumer/interaction_builder_spec.rb +4 -8
- data/spec/support/case-insensitive-response-header-matching.json +21 -0
- data/spec/support/case-insensitive-response-header-matching.rb +15 -0
- data/tasks/pact-test.rake +5 -0
- metadata +42 -122
- data/lib/pact/configuration.rb +0 -195
- data/lib/pact/consumer/app_manager.rb +0 -158
- data/lib/pact/consumer/interactions_filter.rb +0 -48
- data/lib/pact/consumer/mock_service.rb +0 -2
- data/lib/pact/consumer/mock_service/app.rb +0 -82
- data/lib/pact/consumer/mock_service/interaction_delete.rb +0 -33
- data/lib/pact/consumer/mock_service/interaction_list.rb +0 -76
- data/lib/pact/consumer/mock_service/interaction_mismatch.rb +0 -73
- data/lib/pact/consumer/mock_service/interaction_post.rb +0 -31
- data/lib/pact/consumer/mock_service/interaction_replay.rb +0 -139
- data/lib/pact/consumer/mock_service/log_get.rb +0 -28
- data/lib/pact/consumer/mock_service/missing_interactions_get.rb +0 -30
- data/lib/pact/consumer/mock_service/mock_service_administration_endpoint.rb +0 -31
- data/lib/pact/consumer/mock_service/pact_post.rb +0 -33
- data/lib/pact/consumer/mock_service/rack_request_helper.rb +0 -51
- data/lib/pact/consumer/mock_service/verification_get.rb +0 -68
- data/lib/pact/consumer/mock_service_client.rb +0 -65
- data/lib/pact/consumer/mock_service_interaction_expectation.rb +0 -37
- data/lib/pact/consumer/request.rb +0 -27
- data/lib/pact/consumer/server.rb +0 -90
- data/lib/pact/consumer_contract.rb +0 -1
- data/lib/pact/consumer_contract/consumer_contract.rb +0 -115
- data/lib/pact/consumer_contract/consumer_contract_writer.rb +0 -84
- data/lib/pact/consumer_contract/file_name.rb +0 -19
- data/lib/pact/consumer_contract/headers.rb +0 -51
- data/lib/pact/consumer_contract/interaction.rb +0 -67
- data/lib/pact/consumer_contract/pact_file.rb +0 -24
- data/lib/pact/consumer_contract/request.rb +0 -73
- data/lib/pact/consumer_contract/service_consumer.rb +0 -28
- data/lib/pact/consumer_contract/service_provider.rb +0 -28
- data/lib/pact/logging.rb +0 -14
- data/lib/pact/matchers.rb +0 -1
- data/lib/pact/matchers/actual_type.rb +0 -16
- data/lib/pact/matchers/base_difference.rb +0 -37
- data/lib/pact/matchers/differ.rb +0 -153
- data/lib/pact/matchers/difference.rb +0 -13
- data/lib/pact/matchers/difference_indicator.rb +0 -26
- data/lib/pact/matchers/embedded_diff_formatter.rb +0 -62
- data/lib/pact/matchers/expected_type.rb +0 -35
- data/lib/pact/matchers/index_not_found.rb +0 -15
- data/lib/pact/matchers/list_diff_formatter.rb +0 -101
- data/lib/pact/matchers/matchers.rb +0 -139
- data/lib/pact/matchers/no_diff_indicator.rb +0 -18
- data/lib/pact/matchers/regexp_difference.rb +0 -13
- data/lib/pact/matchers/type_difference.rb +0 -16
- data/lib/pact/matchers/unexpected_index.rb +0 -11
- data/lib/pact/matchers/unexpected_key.rb +0 -11
- data/lib/pact/matchers/unix_diff_formatter.rb +0 -114
- data/lib/pact/reification.rb +0 -28
- data/lib/pact/rspec.rb +0 -53
- data/lib/pact/shared/active_support_support.rb +0 -51
- data/lib/pact/shared/dsl.rb +0 -76
- data/lib/pact/shared/jruby_support.rb +0 -18
- data/lib/pact/shared/json_differ.rb +0 -15
- data/lib/pact/shared/key_not_found.rb +0 -15
- data/lib/pact/shared/null_expectation.rb +0 -31
- data/lib/pact/shared/request.rb +0 -80
- data/lib/pact/shared/text_differ.rb +0 -14
- data/lib/pact/something_like.rb +0 -49
- data/lib/pact/symbolize_keys.rb +0 -12
- data/lib/pact/term.rb +0 -85
- data/spec/lib/pact/consumer/request_spec.rb +0 -24
- data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -180
- data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -107
- data/spec/lib/pact/consumer_contract/request_spec.rb +0 -329
- data/spec/lib/pact/matchers/differ_spec.rb +0 -214
- data/spec/lib/pact/matchers/difference_spec.rb +0 -22
- data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
- data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
- data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -114
- data/spec/lib/pact/matchers/matchers_spec.rb +0 -500
- data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
- data/spec/lib/pact/matchers/type_difference_spec.rb +0 -34
- data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
- data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
- data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -216
- data/spec/lib/pact/reification_spec.rb +0 -67
- data/spec/lib/pact/shared/dsl_spec.rb +0 -86
- data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
- data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
- data/spec/lib/pact/shared/request_spec.rb +0 -111
- data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
- data/spec/lib/pact/something_like_spec.rb +0 -21
- data/spec/lib/pact/term_spec.rb +0 -89
- data/spec/support/dsl_spec_support.rb +0 -7
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/shared/json_differ'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
describe JsonDiffer do
|
|
6
|
-
|
|
7
|
-
describe ".call" do
|
|
8
|
-
|
|
9
|
-
let(:expected) { {'a' => 'b'} }
|
|
10
|
-
|
|
11
|
-
subject { JsonDiffer.call(expected, actual) }
|
|
12
|
-
|
|
13
|
-
context "when the actual is valid JSON" do
|
|
14
|
-
|
|
15
|
-
let(:actual) { {'a' => 'c'} }
|
|
16
|
-
let(:difference) { {'a' => Pact::Matchers::Difference.new('b', 'c')} }
|
|
17
|
-
|
|
18
|
-
context "when the actual does not equal the expected" do
|
|
19
|
-
it "parses the JSON and returns a diff" do
|
|
20
|
-
expect(subject).to eq(difference)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "when the actual equals the expected" do
|
|
25
|
-
let(:actual) { expected }
|
|
26
|
-
it "parses the JSON and returns an empty diff" do
|
|
27
|
-
expect(subject.any?).to be false
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/shared/key_not_found'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
describe KeyNotFound do
|
|
6
|
-
|
|
7
|
-
describe "#as_json" do
|
|
8
|
-
it "returns a string representation of the object" do
|
|
9
|
-
expect(subject.as_json).to eq subject.to_s
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe "#to_json" do
|
|
14
|
-
it "serialises the object to JSON" do
|
|
15
|
-
expect(subject.to_json).to eq "\"#{subject.to_s}\""
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/shared/request'
|
|
3
|
-
require 'pact/shared/key_not_found'
|
|
4
|
-
|
|
5
|
-
module Pact
|
|
6
|
-
|
|
7
|
-
module Request
|
|
8
|
-
|
|
9
|
-
describe Base do
|
|
10
|
-
|
|
11
|
-
class TestRequest < Base
|
|
12
|
-
|
|
13
|
-
def self.key_not_found
|
|
14
|
-
Pact::KeyNotFound.new
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
subject { TestRequest.new("get", "/", {some: "things"}, {some: "things"} , "some=things") }
|
|
20
|
-
|
|
21
|
-
describe "#to_json" do
|
|
22
|
-
it "renders the keys in a sensible order" do
|
|
23
|
-
expect(subject.to_json).to match(/method.*path.*query.*headers.*body/)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe "#full_path" do
|
|
28
|
-
|
|
29
|
-
subject { TestRequest.new("get", "/something", {}, {some: "things"} , query).full_path }
|
|
30
|
-
|
|
31
|
-
context "with a query that is a Pact::Term" do
|
|
32
|
-
let(:query) { Pact::Term.new(generate: "some=things", matcher: /some/) }
|
|
33
|
-
it "reifies and appends the query" do
|
|
34
|
-
expect(subject).to eq("/something?some=things")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context "with a query that is a string" do
|
|
39
|
-
let(:query) { "some=things" }
|
|
40
|
-
it "appends the query" do
|
|
41
|
-
expect(subject).to eq("/something?some=things")
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "with an empty query" do
|
|
46
|
-
let(:query) { "" }
|
|
47
|
-
it "does include a query" do
|
|
48
|
-
expect(subject).to eq("/something")
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
context "with a nil query" do
|
|
53
|
-
let(:query) { nil }
|
|
54
|
-
it "does not include a query" do
|
|
55
|
-
expect(subject).to eq("/something")
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe "#method_and_path" do
|
|
61
|
-
context "with an empty path" do
|
|
62
|
-
subject { TestRequest.new("get", "", {}, {} , "").method_and_path }
|
|
63
|
-
|
|
64
|
-
it "includes a slash" do
|
|
65
|
-
expect(subject).to eq("GET /")
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "with a path" do
|
|
70
|
-
subject { TestRequest.new("get", "/something", {}, {} , "").method_and_path }
|
|
71
|
-
|
|
72
|
-
it "includes the path" do
|
|
73
|
-
expect(subject).to eq("GET /something")
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
context "with a query" do
|
|
78
|
-
subject { TestRequest.new("get", "/something", {}, {} , "test=query").method_and_path }
|
|
79
|
-
|
|
80
|
-
it "includes the query" do
|
|
81
|
-
expect(subject).to eq("GET /something?test=query")
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
describe "#content_type" do
|
|
87
|
-
|
|
88
|
-
subject { TestRequest.new("get", "/something", headers, {} , "") }
|
|
89
|
-
context "when there are no expected headers" do
|
|
90
|
-
let(:headers) { Pact::KeyNotFound.new }
|
|
91
|
-
it "returns nil" do
|
|
92
|
-
expect(subject.send(:content_type)).to be nil
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
context "when there is no Content-Type header" do
|
|
96
|
-
let(:headers) { {} }
|
|
97
|
-
it "returns the content-type" do
|
|
98
|
-
expect(subject.send(:content_type)).to be nil
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
context "when there is a content-type header (" do
|
|
102
|
-
let(:headers) { {'content-type' => 'blah'} }
|
|
103
|
-
it "returns the content-type" do
|
|
104
|
-
expect(subject.send(:content_type)).to eq 'blah'
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/shared/text_differ'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
describe TextDiffer do
|
|
6
|
-
|
|
7
|
-
describe ".call" do
|
|
8
|
-
|
|
9
|
-
subject { TextDiffer.call expected, actual }
|
|
10
|
-
|
|
11
|
-
let(:expected) { "This is the string you are looking for" }
|
|
12
|
-
|
|
13
|
-
context "when the expected and actual are both strings" do
|
|
14
|
-
|
|
15
|
-
context "when they equal each other" do
|
|
16
|
-
let(:actual) { "This is the string you are looking for" }
|
|
17
|
-
|
|
18
|
-
it "returns an empty diff" do
|
|
19
|
-
expect(subject.any?).to be false
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context "when they don't equal each other" do
|
|
24
|
-
let(:actual) { "This is not the string you are looking for" }
|
|
25
|
-
|
|
26
|
-
it "returns the diff" do
|
|
27
|
-
expect(subject).to eq Pact::Matchers::Difference.new(expected, actual)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context "when the actual is not a String" do
|
|
33
|
-
let(:actual) { {some: 'hash'} }
|
|
34
|
-
let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
|
|
35
|
-
it "returns the diff" do
|
|
36
|
-
expect(subject)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context "when the expected and actual are both objects" do
|
|
41
|
-
let(:actual) { {some: 'hash', blah: 'blah'} }
|
|
42
|
-
let(:expected) { {some: 'hash'} }
|
|
43
|
-
let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
|
|
44
|
-
|
|
45
|
-
it "returns the diff using the JSON matching logic, allowing extra keys. But should it really if the expected Content-Type isn't actually JSON?" do
|
|
46
|
-
expect(subject)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "potentially should treat both expected and actual as Strings"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Pact
|
|
4
|
-
describe SomethingLike do
|
|
5
|
-
describe 'json_create' do
|
|
6
|
-
let(:json) do
|
|
7
|
-
'
|
|
8
|
-
{
|
|
9
|
-
"json_class": "Pact::SomethingLike",
|
|
10
|
-
"contents" : { "thing" : "blah" }
|
|
11
|
-
}
|
|
12
|
-
'
|
|
13
|
-
end
|
|
14
|
-
subject { SomethingLike.json_create(JSON.parse(json)) }
|
|
15
|
-
it "creates a SomethingLike object from json" do
|
|
16
|
-
expect(subject).to eq(SomethingLike.new({"thing" => "blah"}))
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
data/spec/lib/pact/term_spec.rb
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module Pact
|
|
4
|
-
describe Term do
|
|
5
|
-
|
|
6
|
-
describe 'initialize' do
|
|
7
|
-
let(:matcher) { /e/ }
|
|
8
|
-
let(:generate) { 'apple'}
|
|
9
|
-
subject { Term.new(generate: generate, matcher: matcher) }
|
|
10
|
-
context "when a matcher and generate are specified" do
|
|
11
|
-
context "when the matcher matches the generated value" do
|
|
12
|
-
it 'does not raise an exception' do
|
|
13
|
-
subject
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context "when the matcher does not match the generated value" do
|
|
18
|
-
let(:generate) { 'banana' }
|
|
19
|
-
it 'raises an exception' do
|
|
20
|
-
expect { subject }.to raise_error /does not match/
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
context 'when a matcher is not specified' do
|
|
25
|
-
let(:matcher) { nil }
|
|
26
|
-
it 'raises an exception' do
|
|
27
|
-
expect { subject }.to raise_error /Please specify a matcher/
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
context 'when a generate is not specified' do
|
|
31
|
-
let(:generate) { nil }
|
|
32
|
-
it 'raises an exception' do
|
|
33
|
-
expect { subject }.to raise_error /Please specify a value/
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "equality" do
|
|
39
|
-
context "when the matcher and generate attrs are the same" do
|
|
40
|
-
let(:this) { Term.new(generate: 'A', matcher: /A/) }
|
|
41
|
-
let(:that) { Term.new(generate: 'A', matcher: /A/) }
|
|
42
|
-
|
|
43
|
-
it "is equal" do
|
|
44
|
-
expect(this).to eq that
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context "when the generate attrs are different" do
|
|
49
|
-
let(:this) { Term.new(generate: 'A', matcher: /.*/) }
|
|
50
|
-
let(:that) { Term.new(generate: 'B', matcher: /.*/) }
|
|
51
|
-
|
|
52
|
-
it "is not equal" do
|
|
53
|
-
expect(this).to_not eq that
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when the matcher attrs are different" do
|
|
58
|
-
let(:this) { Term.new(matcher: /A/, generate: 'AB') }
|
|
59
|
-
let(:that) { Term.new(matcher: /B/, generate: 'AB') }
|
|
60
|
-
|
|
61
|
-
it "is not equal" do
|
|
62
|
-
expect(this).to_not eq that
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe 'empty?' do
|
|
68
|
-
|
|
69
|
-
subject { Term.new(generate: 'some', matcher: /some/) }
|
|
70
|
-
|
|
71
|
-
it 'should return false' do
|
|
72
|
-
expect(subject).to_not be_empty
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
describe 'unpack_regexps' do
|
|
78
|
-
let(:term) { Term.new(generate: 'some', matcher: /s/) }
|
|
79
|
-
let(:body) { [{a: [{b: term}], c:term, d: 1, e: 'blah'}] }
|
|
80
|
-
let(:expected) { [{:a=>[{:b=>/s/}], :c=>/s/, :d=>1, :e=>"blah"}] }
|
|
81
|
-
|
|
82
|
-
it "returns a structure with the Pact::Terms replaced by their regexps" do
|
|
83
|
-
expect(Term.unpack_regexps(body)).to eq expected
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
end
|
|
89
|
-
end
|