pact-support 1.11.0 → 1.12.0

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/lib/pact/consumer_contract/consumer_contract.rb +11 -0
  4. data/lib/pact/consumer_contract/interaction.rb +4 -1
  5. data/lib/pact/consumer_contract/interaction_v2_parser.rb +9 -1
  6. data/lib/pact/consumer_contract/interaction_v3_parser.rb +10 -1
  7. data/lib/pact/support/version.rb +1 -1
  8. metadata +4 -227
  9. data/.github/ISSUE_TEMPLATE.md +0 -33
  10. data/.gitignore +0 -32
  11. data/.rspec +0 -3
  12. data/.travis.yml +0 -29
  13. data/Appraisals +0 -7
  14. data/Gemfile +0 -4
  15. data/RELEASING.md +0 -5
  16. data/Rakefile +0 -4
  17. data/gemfiles/default.gemfile +0 -5
  18. data/gemfiles/ruby_under_22.gemfile +0 -8
  19. data/pact-support.gemspec +0 -39
  20. data/script/release.sh +0 -9
  21. data/script/update-pact-specification-v2 +0 -9
  22. data/spec/fixtures/interaction-with-matching-rules.json +0 -27
  23. data/spec/fixtures/multipart-form-diff.txt +0 -9
  24. data/spec/fixtures/not-a-pact.json +0 -3
  25. data/spec/fixtures/pact-http-v2.json +0 -36
  26. data/spec/fixtures/pact-http-v3.json +0 -36
  27. data/spec/integration/matching_rules_extract_and_merge_spec.rb +0 -127
  28. data/spec/lib/pact/array_like_spec.rb +0 -37
  29. data/spec/lib/pact/configuration_spec.rb +0 -61
  30. data/spec/lib/pact/consumer/request_spec.rb +0 -25
  31. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  32. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -142
  33. data/spec/lib/pact/consumer_contract/file_name_spec.rb +0 -24
  34. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  35. data/spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb +0 -25
  36. data/spec/lib/pact/consumer_contract/interaction_parser_spec.rb +0 -62
  37. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -121
  38. data/spec/lib/pact/consumer_contract/interaction_v2_parser_spec.rb +0 -54
  39. data/spec/lib/pact/consumer_contract/interaction_v3_parser_spec.rb +0 -48
  40. data/spec/lib/pact/consumer_contract/pact_file_spec.rb +0 -204
  41. data/spec/lib/pact/consumer_contract/query_hash_spec.rb +0 -154
  42. data/spec/lib/pact/consumer_contract/query_string_spec.rb +0 -131
  43. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -486
  44. data/spec/lib/pact/consumer_contract/response_spec.rb +0 -82
  45. data/spec/lib/pact/helpers_spec.rb +0 -143
  46. data/spec/lib/pact/matchers/differ_spec.rb +0 -215
  47. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  48. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  49. data/spec/lib/pact/matchers/extract_diff_messages_spec.rb +0 -78
  50. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  51. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -121
  52. data/spec/lib/pact/matchers/matchers_array_like_spec.rb +0 -222
  53. data/spec/lib/pact/matchers/matchers_messages_hash_and_array_spec.rb +0 -146
  54. data/spec/lib/pact/matchers/matchers_messages_mismatched_value_spec.rb +0 -72
  55. data/spec/lib/pact/matchers/matchers_messages_regexp_spec.rb +0 -103
  56. data/spec/lib/pact/matchers/matchers_spec.rb +0 -561
  57. data/spec/lib/pact/matchers/multipart_form_diff_formatter_spec.rb +0 -36
  58. data/spec/lib/pact/matchers/no_diff_at_index_spec.rb +0 -15
  59. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  60. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -36
  61. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  62. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  63. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -235
  64. data/spec/lib/pact/matching_rules/extract_spec.rb +0 -216
  65. data/spec/lib/pact/matching_rules/merge_spec.rb +0 -436
  66. data/spec/lib/pact/matching_rules/v3/extract_spec.rb +0 -238
  67. data/spec/lib/pact/matching_rules/v3/merge_spec.rb +0 -485
  68. data/spec/lib/pact/matching_rules_spec.rb +0 -82
  69. data/spec/lib/pact/reification_spec.rb +0 -172
  70. data/spec/lib/pact/shared/dsl_spec.rb +0 -100
  71. data/spec/lib/pact/shared/form_differ_spec.rb +0 -71
  72. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  73. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  74. data/spec/lib/pact/shared/multipart_form_differ_spec.rb +0 -49
  75. data/spec/lib/pact/shared/request_spec.rb +0 -235
  76. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  77. data/spec/lib/pact/something_like_spec.rb +0 -23
  78. data/spec/lib/pact/support_spec.rb +0 -9
  79. data/spec/lib/pact/symbolize_keys_spec.rb +0 -15
  80. data/spec/lib/pact/term_spec.rb +0 -89
  81. data/spec/pact_specification/compliance-2.0.rb +0 -66
  82. data/spec/spec_helper.rb +0 -18
  83. data/spec/support/a_consumer-a_producer.json +0 -32
  84. data/spec/support/a_consumer-a_provider.json +0 -32
  85. data/spec/support/active_support_if_configured.rb +0 -6
  86. data/spec/support/case-insensitive-response-header-matching.json +0 -21
  87. data/spec/support/consumer_contract_template.json +0 -24
  88. data/spec/support/dsl_spec_support.rb +0 -7
  89. data/spec/support/factories.rb +0 -87
  90. data/spec/support/generated_index.md +0 -4
  91. data/spec/support/generated_markdown.md +0 -55
  92. data/spec/support/interaction_view_model.json +0 -63
  93. data/spec/support/interaction_view_model_with_terms.json +0 -50
  94. data/spec/support/markdown_pact.json +0 -48
  95. data/spec/support/missing_provider_states_output.txt +0 -25
  96. data/spec/support/options.json +0 -21
  97. data/spec/support/ruby_version_helpers.rb +0 -23
  98. data/spec/support/shared_examples_for_request.rb +0 -132
  99. data/spec/support/spec_support.rb +0 -29
  100. data/spec/support/stubbing.json +0 -22
  101. data/spec/support/term.json +0 -48
  102. data/spec/support/test_app_fail.json +0 -61
  103. data/spec/support/test_app_pass.json +0 -38
  104. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  105. data/tasks/release.rake +0 -5
  106. data/tasks/spec.rake +0 -14
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/shared_examples_for_request'
3
- require 'pact/consumer/request'
4
-
5
- module Pact
6
- describe Consumer::Request::Actual do
7
- it_behaves_like "a request"
8
-
9
- let(:raw_request) do
10
- {
11
- 'method' => 'get',
12
- 'path' => '/mallory'
13
- }
14
- end
15
-
16
- describe "from_hash" do
17
- context "when field are not defined" do
18
- subject { described_class.from_hash(raw_request) }
19
- it "raises an error" do
20
- expect{subject}.to raise_error KeyError
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/active_support_support'
3
-
4
- module Pact
5
- describe ActiveSupportSupport do
6
-
7
- include ActiveSupportSupport
8
-
9
-
10
- describe "fix_regexp" do
11
- let(:regexp) { /moose/ }
12
-
13
- subject { fix_regexp regexp }
14
-
15
- it "returns the original regexp" do
16
- expect(subject).to be(regexp)
17
- end
18
-
19
- it "fixes the as_json method for Regexp that ActiveSupport tramples beneath its destructive hooves of destruction" do
20
- expect(subject.to_json).to eq("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"moose\"}")
21
- end
22
- end
23
-
24
- describe "fix_all_the_things" do
25
- let(:hash) do
26
- { 'body' => Pact::Term.new(matcher: /a*b/, generate: 'abba'), array: [/blah/], thing: /alligator/ }
27
- end
28
-
29
- subject { fix_all_the_things(hash) }
30
-
31
- it "returns the original object" do
32
- expect(subject).to be(hash)
33
- end
34
-
35
- it "finds all the Regexp objects in hashes or Pact class attributes and fixes the as_json method" do
36
- json = subject.to_json
37
- expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"a*b\"}")
38
- expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"blah\"}")
39
- expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"alligator\"}")
40
- end
41
- end
42
-
43
- describe "fix_json_formatting" do
44
- let(:active_support_affected_pretty_generated_json) { "{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"a*b\"}" }
45
- let(:pretty_generated_json) do
46
- '{
47
- "json_class": "Regexp",
48
- "o": 0,
49
- "s": "a*b"
50
- }'
51
- end
52
-
53
- it "pretty formats the json that has been not pretty formatted because of ActiveSupport" do
54
- expect(fix_json_formatting(active_support_affected_pretty_generated_json)).to eq (pretty_generated_json.strip)
55
- end
56
- end
57
- end
58
- end
@@ -1,142 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/consumer_contract'
3
-
4
- module Pact
5
- describe ConsumerContract do
6
- describe "from_uri" do
7
- context "when the URL does not point to a valid pact" do
8
- subject { ConsumerContract.from_uri('spec/fixtures/not-a-pact.json') }
9
-
10
- it "raises a helpful error" do
11
- expect { subject }.to raise_error UnrecognizePactFormatError, /Please check that spec/
12
- end
13
- end
14
- end
15
-
16
- describe "from_hash" do
17
- context "when the hash is not a valid pact" do
18
- subject { ConsumerContract.from_hash({'foo' => 'bar'}) }
19
-
20
- it "raises a helpful error" do
21
- expect { subject }.to raise_error UnrecognizePactFormatError, 'This document does not use a recognised Pact format: {"foo"=>"bar"}'
22
- end
23
- end
24
- end
25
-
26
- describe ".from_json" do
27
-
28
- let(:loaded_pact) { ConsumerContract.from_json(string) }
29
-
30
- context "with an HTTP contract" do
31
- context "when the top level object is a ConsumerContract" do
32
- let(:string) { '{"interactions":[{"request": {"path":"/path", "method" : "get"}, "response": {"status" : 200}}], "consumer": {"name" : "Bob"} , "provider": {"name" : "Mary"} }' }
33
-
34
- it "should create a Pact" do
35
- expect(loaded_pact).to be_instance_of ConsumerContract
36
- end
37
-
38
- it "should have interactions" do
39
- expect(loaded_pact.interactions).to be_instance_of Array
40
- end
41
-
42
- it "should have a consumer" do
43
- expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
44
- end
45
-
46
- it "should have a provider" do
47
- expect(loaded_pact.provider).to be_instance_of Pact::ServiceProvider
48
- end
49
- end
50
-
51
- context "with old 'producer' key" do
52
- let(:string) { File.read('./spec/support/a_consumer-a_producer.json')}
53
- it "should create a Pact" do
54
- expect(loaded_pact).to be_instance_of ConsumerContract
55
- end
56
-
57
- it "should have interactions" do
58
- expect(loaded_pact.interactions).to be_instance_of Array
59
- end
60
-
61
- it "should have a consumer" do
62
- expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
63
- end
64
-
65
- it "should have a provider" do
66
- expect(loaded_pact.provider).to be_instance_of Pact::ServiceProvider
67
- expect(loaded_pact.provider.name).to eq "an old producer"
68
- end
69
-
70
- it "should have a provider_state" do
71
- expect(loaded_pact.interactions.first.provider_state).to eq 'state one'
72
- end
73
- end
74
- end
75
- end
76
-
77
- describe "find_interactions" do
78
- let(:consumer) { double('Pact::ServiceConsumer', :name => 'Consumer')}
79
- let(:provider) { double('Pact::ServiceProvider', :name => 'Provider')}
80
- let(:interaction) { double('Pact::Interaction') }
81
- subject { ConsumerContract.new(:interactions => [interaction], :consumer => consumer, :provider => provider) }
82
- let(:criteria) { {:description => /blah/} }
83
- before do
84
- expect(interaction).to receive(:matches_criteria?).with(criteria).and_return(matches)
85
- end
86
- context "by description" do
87
- context "when no interactions are found" do
88
- let(:matches) { false }
89
- it "returns an empty array" do
90
- expect(subject.find_interactions(criteria)).to eql []
91
- end
92
- end
93
- context "when interactions are found" do
94
- let(:matches) { true }
95
- it "returns an array of the matching interactions" do
96
- expect(subject.find_interactions(criteria)).to eql [interaction]
97
- end
98
- end
99
- end
100
- end
101
-
102
- describe "find_interaction" do
103
- let(:consumer) { double('Pact::ServiceConsumer', :name => 'Consumer')}
104
- let(:provider) { double('Pact::ServiceProvider', :name => 'Provider')}
105
- let(:interaction1) { double('Pact::Interaction') }
106
- let(:interaction2) { double('Pact::Interaction') }
107
- let(:criteria) { {:description => /blah/} }
108
-
109
- before do
110
- expect(interaction1).to receive(:matches_criteria?).with(criteria).and_return(matches1)
111
- expect(interaction2).to receive(:matches_criteria?).with(criteria).and_return(matches2)
112
- end
113
-
114
- subject { ConsumerContract.new(:interactions => [interaction1, interaction2], :consumer => consumer, :provider => provider) }
115
- context "by description" do
116
- context "when a match is found" do
117
- let(:matches1) { true }
118
- let(:matches2) { false }
119
-
120
- it "returns the interaction" do
121
- expect(subject.find_interaction criteria).to eql interaction1
122
- end
123
- end
124
- context "when more than one match is found" do
125
- let(:matches1) { true }
126
- let(:matches2) { true }
127
- it "raises an error" do
128
- expect{ subject.find_interaction(criteria) }.to raise_error "Found more than 1 interaction matching {:description=>/blah/} in pact file between Consumer and Provider."
129
- end
130
- end
131
- context "when a match is not found" do
132
- let(:matches1) { false }
133
- let(:matches2) { false }
134
- it "raises an error" do
135
- expect{ subject.find_interaction(criteria) }.to raise_error "Could not find interaction matching {:description=>/blah/} in pact file between Consumer and Provider."
136
- end
137
- end
138
- end
139
- end
140
-
141
- end
142
- end
@@ -1,24 +0,0 @@
1
- require 'pact/consumer_contract/file_name'
2
-
3
- module Pact
4
- describe FileName do
5
- describe "file_path" do
6
-
7
- subject { FileName.file_path 'foo', 'bar', 'tmp/pacts' }
8
- it { is_expected.to eq 'tmp/pacts/foo-bar.json' }
9
-
10
- context "when unique is true" do
11
- subject { FileName.file_path 'foo', 'bar', 'tmp/pacts', unique: true }
12
- it { is_expected.to match %r{tmp/pacts/foo-bar-\d+.json} }
13
- end
14
-
15
- context "when the path includes backslashes" do
16
- subject { FileName.file_path 'foo', 'bar', 'c:\tmp\pacts' }
17
-
18
- it "changes them to forward slashes" do
19
- expect(subject).to eq "c:/tmp/pacts/foo-bar.json"
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,107 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/consumer_contract/headers'
3
-
4
- module Pact
5
- describe Headers do
6
-
7
- describe "initialize" do
8
-
9
- context "with duplicate headers" do
10
-
11
- subject { Headers.new('Content-Type' => 'application/hippo', 'CONTENT-TYPE' => 'application/giraffe') }
12
-
13
- it "raises an error" do
14
- expect { subject }.to raise_error DuplicateHeaderError, /Content\-Type.*CONTENT\-TYPE/
15
- end
16
-
17
- end
18
-
19
- context "with a symbol as a header name" do
20
-
21
- subject { Headers.new(:'content-type' => 'application/hippo') }
22
-
23
- it "converts the header name to a String" do
24
- expect( subject.to_hash ).to eq 'content-type' => 'application/hippo'
25
- end
26
-
27
- end
28
-
29
- context "with a nil header name" do
30
-
31
- subject { Headers.new(nil => 'application/hippo') }
32
-
33
- it "raises an error" do
34
- expect{ subject }.to raise_error InvalidHeaderNameTypeError
35
- end
36
-
37
- end
38
-
39
- context "with a boolean header name" do
40
-
41
- subject { Headers.new(false => 'application/hippo') }
42
-
43
- it "raises an error" do
44
- expect{ subject }.to raise_error InvalidHeaderNameTypeError
45
- end
46
-
47
- end
48
-
49
- end
50
-
51
- describe "[]" do
52
-
53
- subject { Headers.new 'Content-Type' => 'application/hippo' }
54
-
55
- it "is case insensitive as HTTP headers are case insensitive" do
56
- expect(subject['Content-Type']).to eq('application/hippo')
57
- expect(subject['CONTENT-TYPE']).to eq('application/hippo')
58
- expect(subject['content-type']).to eq('application/hippo')
59
- end
60
-
61
- end
62
-
63
- describe "fetch" do
64
-
65
- subject { Headers.new 'Content-Type' => 'application/hippo' }
66
-
67
- it "is case insensitive as HTTP headers are case insensitive" do
68
- expect(subject.fetch('Content-Type')).to eq('application/hippo')
69
- expect(subject.fetch('CONTENT-TYPE')).to eq('application/hippo')
70
- expect(subject.fetch('content-type')).to eq('application/hippo')
71
- expect(subject.fetch('Content-Length','1')).to eq('1')
72
- expect { subject.fetch('Content-Length')}.to raise_error KeyError
73
- end
74
-
75
- end
76
-
77
- describe "key?" do
78
-
79
- subject { Headers.new 'Content-Type' => 'application/hippo' }
80
-
81
- it "is case insensitive as HTTP headers are case insensitive" do
82
- expect(subject.key?('CONTENT-TYPE')).to be true
83
- expect(subject.key?('CONTENT-LENGTH')).to be false
84
- end
85
- end
86
-
87
- describe "has_key?" do
88
-
89
- subject { Headers.new 'Content-Type' => 'application/hippo' }
90
-
91
- it "is case insensitive as HTTP headers are case insensitive" do
92
- expect(subject.has_key?('CONTENT-TYPE')).to be true
93
- expect(subject.has_key?('CONTENT-LENGTH')).to be false
94
- end
95
- end
96
-
97
- describe "[]=" do
98
-
99
- subject { Headers.new }
100
-
101
- it "does not allow modification" do
102
- expect{ subject['Content-Type'] = 'application/hippo' }.to raise_error /frozen/
103
- end
104
-
105
- end
106
- end
107
- end
@@ -1,25 +0,0 @@
1
- require 'pact/consumer_contract/http_consumer_contract_parser'
2
-
3
- module Pact
4
- describe HttpConsumerContractParser do
5
- describe "#call integration test" do
6
- subject { HttpConsumerContractParser.new.call(pact_hash) }
7
-
8
- context "with a v2 pact" do
9
- let(:pact_hash) { load_json_fixture('pact-http-v2.json') }
10
-
11
- it "correctly parses the pact" do
12
- expect(subject.interactions.first.response.headers['Content-Type']).to be_a(Pact::Term)
13
- end
14
- end
15
-
16
- context "with a v3 pact" do
17
- let(:pact_hash) { load_json_fixture('pact-http-v3.json') }
18
-
19
- it "correctly parses the pact" do
20
- expect(subject.interactions.first.response.body['foo']).to be_a(Pact::SomethingLike)
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,62 +0,0 @@
1
- require 'pact/consumer_contract/interaction_parser'
2
-
3
- module Pact
4
- describe InteractionParser do
5
- describe ".call" do
6
-
7
- let(:request) { {method: 'get', path: 'path'} }
8
- let(:response) { {} }
9
-
10
- context "when providerState has been used instead of provider_state" do
11
-
12
- subject { InteractionParser.call('response' => response, 'request' => request, 'providerState' => 'some state') }
13
-
14
- it "recognises the provider state" do
15
- expect(subject.provider_state).to eq 'some state'
16
- end
17
- end
18
-
19
- context "when there are matching rules" do
20
- let(:hash) { load_json_fixture 'interaction-with-matching-rules.json' }
21
-
22
- subject { InteractionParser.call(hash, pact_specification_version: Pact::SpecificationVersion.new("2")) }
23
-
24
- it "merges the rules with the example for the request" do
25
- expect(subject.request.body['name']).to be_instance_of(Pact::Term)
26
- end
27
-
28
- it "merges the rules with the example for the response" do
29
- expect(subject.response.body['_links']['self']['href']).to be_instance_of(Pact::Term)
30
- end
31
- end
32
-
33
- context "when the request body is a String" do
34
- let(:hash) { { 'request' => request, 'response' => response } }
35
- subject { InteractionParser.call(hash, pact_specification_version: Pact::SpecificationVersion.new("3")) }
36
-
37
- let(:request) { { 'method' => 'get', 'path' => 'path' , 'body' => "<xml></xml>", 'matchingRules' => {"body" => {"foo" => "bar"} } } }
38
-
39
- it "returns an interaction with an StringWithMatchingRules in the request" do
40
- expect(subject.request.body).to be_a(Pact::StringWithMatchingRules)
41
- expect(subject.request.body).to eq "<xml></xml>"
42
- expect(subject.request.body.matching_rules).to eq "foo" => "bar"
43
- expect(subject.request.body.pact_specification_version).to eq Pact::SpecificationVersion.new("3")
44
- end
45
- end
46
-
47
- context "when the response body is a String" do
48
- let(:hash) { { 'request' => request, 'response' => response } }
49
- subject { InteractionParser.call(hash, pact_specification_version: Pact::SpecificationVersion.new("3")) }
50
-
51
- let(:response) { { 'status' => '200', 'body' => "<xml></xml>", 'matchingRules' => {"body" => {"foo" => "bar"} } } }
52
-
53
- it "returns an interaction with an StringWithMatchingRules in the response" do
54
- expect(subject.response.body).to be_a(Pact::StringWithMatchingRules)
55
- expect(subject.response.body).to eq "<xml></xml>"
56
- expect(subject.response.body.matching_rules).to eq "foo" => "bar"
57
- expect(subject.response.body.pact_specification_version).to eq Pact::SpecificationVersion.new("3")
58
- end
59
- end
60
- end
61
- end
62
- end