pact 1.3.3 → 1.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/CHANGELOG.md +16 -1
  2. data/Gemfile +5 -0
  3. data/Gemfile.lock +34 -13
  4. data/README.md +3 -2
  5. data/example/animal-service/lib/animal_service/api.rb +1 -0
  6. data/example/zoo-app/lib/zoo_app/animal_service_client.rb +0 -9
  7. data/example/zoo-app/lib/zoo_app/models/alligator.rb +2 -0
  8. data/lib/pact.rb +6 -5
  9. data/lib/pact/cli.rb +0 -26
  10. data/lib/pact/consumer/configuration.rb +0 -1
  11. data/lib/pact/consumer/configuration/configuration_extensions.rb +51 -0
  12. data/lib/pact/consumer/consumer_contract_builder.rb +1 -2
  13. data/lib/pact/consumer/interaction_builder.rb +2 -4
  14. data/lib/pact/doc/interaction_view_model.rb +9 -6
  15. data/lib/pact/doc/sort_interactions.rb +1 -1
  16. data/lib/pact/provider/rspec.rb +11 -9
  17. data/lib/pact/version.rb +1 -1
  18. data/pact.gemspec +5 -0
  19. data/spec/lib/pact/consumer/interaction_builder_spec.rb +4 -8
  20. data/spec/support/case-insensitive-response-header-matching.json +21 -0
  21. data/spec/support/case-insensitive-response-header-matching.rb +15 -0
  22. data/tasks/pact-test.rake +5 -0
  23. metadata +42 -122
  24. data/lib/pact/configuration.rb +0 -195
  25. data/lib/pact/consumer/app_manager.rb +0 -158
  26. data/lib/pact/consumer/interactions_filter.rb +0 -48
  27. data/lib/pact/consumer/mock_service.rb +0 -2
  28. data/lib/pact/consumer/mock_service/app.rb +0 -82
  29. data/lib/pact/consumer/mock_service/interaction_delete.rb +0 -33
  30. data/lib/pact/consumer/mock_service/interaction_list.rb +0 -76
  31. data/lib/pact/consumer/mock_service/interaction_mismatch.rb +0 -73
  32. data/lib/pact/consumer/mock_service/interaction_post.rb +0 -31
  33. data/lib/pact/consumer/mock_service/interaction_replay.rb +0 -139
  34. data/lib/pact/consumer/mock_service/log_get.rb +0 -28
  35. data/lib/pact/consumer/mock_service/missing_interactions_get.rb +0 -30
  36. data/lib/pact/consumer/mock_service/mock_service_administration_endpoint.rb +0 -31
  37. data/lib/pact/consumer/mock_service/pact_post.rb +0 -33
  38. data/lib/pact/consumer/mock_service/rack_request_helper.rb +0 -51
  39. data/lib/pact/consumer/mock_service/verification_get.rb +0 -68
  40. data/lib/pact/consumer/mock_service_client.rb +0 -65
  41. data/lib/pact/consumer/mock_service_interaction_expectation.rb +0 -37
  42. data/lib/pact/consumer/request.rb +0 -27
  43. data/lib/pact/consumer/server.rb +0 -90
  44. data/lib/pact/consumer_contract.rb +0 -1
  45. data/lib/pact/consumer_contract/consumer_contract.rb +0 -115
  46. data/lib/pact/consumer_contract/consumer_contract_writer.rb +0 -84
  47. data/lib/pact/consumer_contract/file_name.rb +0 -19
  48. data/lib/pact/consumer_contract/headers.rb +0 -51
  49. data/lib/pact/consumer_contract/interaction.rb +0 -67
  50. data/lib/pact/consumer_contract/pact_file.rb +0 -24
  51. data/lib/pact/consumer_contract/request.rb +0 -73
  52. data/lib/pact/consumer_contract/service_consumer.rb +0 -28
  53. data/lib/pact/consumer_contract/service_provider.rb +0 -28
  54. data/lib/pact/logging.rb +0 -14
  55. data/lib/pact/matchers.rb +0 -1
  56. data/lib/pact/matchers/actual_type.rb +0 -16
  57. data/lib/pact/matchers/base_difference.rb +0 -37
  58. data/lib/pact/matchers/differ.rb +0 -153
  59. data/lib/pact/matchers/difference.rb +0 -13
  60. data/lib/pact/matchers/difference_indicator.rb +0 -26
  61. data/lib/pact/matchers/embedded_diff_formatter.rb +0 -62
  62. data/lib/pact/matchers/expected_type.rb +0 -35
  63. data/lib/pact/matchers/index_not_found.rb +0 -15
  64. data/lib/pact/matchers/list_diff_formatter.rb +0 -101
  65. data/lib/pact/matchers/matchers.rb +0 -139
  66. data/lib/pact/matchers/no_diff_indicator.rb +0 -18
  67. data/lib/pact/matchers/regexp_difference.rb +0 -13
  68. data/lib/pact/matchers/type_difference.rb +0 -16
  69. data/lib/pact/matchers/unexpected_index.rb +0 -11
  70. data/lib/pact/matchers/unexpected_key.rb +0 -11
  71. data/lib/pact/matchers/unix_diff_formatter.rb +0 -114
  72. data/lib/pact/reification.rb +0 -28
  73. data/lib/pact/rspec.rb +0 -53
  74. data/lib/pact/shared/active_support_support.rb +0 -51
  75. data/lib/pact/shared/dsl.rb +0 -76
  76. data/lib/pact/shared/jruby_support.rb +0 -18
  77. data/lib/pact/shared/json_differ.rb +0 -15
  78. data/lib/pact/shared/key_not_found.rb +0 -15
  79. data/lib/pact/shared/null_expectation.rb +0 -31
  80. data/lib/pact/shared/request.rb +0 -80
  81. data/lib/pact/shared/text_differ.rb +0 -14
  82. data/lib/pact/something_like.rb +0 -49
  83. data/lib/pact/symbolize_keys.rb +0 -12
  84. data/lib/pact/term.rb +0 -85
  85. data/spec/lib/pact/consumer/request_spec.rb +0 -24
  86. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  87. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -180
  88. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  89. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -107
  90. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -329
  91. data/spec/lib/pact/matchers/differ_spec.rb +0 -214
  92. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  93. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  94. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  95. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -114
  96. data/spec/lib/pact/matchers/matchers_spec.rb +0 -500
  97. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  98. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -34
  99. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  100. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  101. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -216
  102. data/spec/lib/pact/reification_spec.rb +0 -67
  103. data/spec/lib/pact/shared/dsl_spec.rb +0 -86
  104. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  105. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  106. data/spec/lib/pact/shared/request_spec.rb +0 -111
  107. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  108. data/spec/lib/pact/something_like_spec.rb +0 -21
  109. data/spec/lib/pact/term_spec.rb +0 -89
  110. data/spec/support/dsl_spec_support.rb +0 -7
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/matchers/regexp_difference'
3
-
4
- module Pact
5
- module Matchers
6
- describe RegexpDifference do
7
-
8
- context "when a regexp is expected" do
9
-
10
- subject { RegexpDifference.new(/ap/, 'pear').as_json }
11
-
12
- it "indicates that the actual was indended 'to match'" do
13
- expect(subject).to eq({:EXPECTED_TO_MATCH => "/ap/", :ACTUAL => "pear"})
14
- end
15
-
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/matchers/type_difference'
3
-
4
- module Pact
5
- module Matchers
6
- describe TypeDifference do
7
-
8
- describe "#as_json" do
9
-
10
- let(:expected) { ExpectedType.new("Fred") }
11
- let(:actual) { ActualType.new(1) }
12
- subject { TypeDifference.new expected, actual }
13
-
14
- context "when the actual is a KeyNotFound" do
15
- let(:actual) { KeyNotFound.new }
16
- let(:expected_hash) { {:EXPECTED_TYPE => "String", :ACTUAL => actual.to_s } }
17
-
18
- it "use the key ACTUAL" do
19
- expect(subject.as_json).to eq(expected_hash)
20
- end
21
- end
22
-
23
- context "when the actual is an ActualType" do
24
- let(:expected_hash) { {:EXPECTED_TYPE => "String", :ACTUAL_TYPE => "Fixnum" } }
25
-
26
- it "uses the key ACTUAL_TYPE" do
27
- expect(subject.as_json).to eq(expected_hash)
28
- end
29
- end
30
-
31
- end
32
- end
33
- end
34
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/matchers/unexpected_index'
3
-
4
- module Pact
5
- describe UnexpectedIndex 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,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/matchers/unexpected_key'
3
-
4
- module Pact
5
- describe UnexpectedKey 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,216 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/matchers/unix_diff_formatter'
3
- require 'pact/matchers/expected_type'
4
- require 'pact/matchers/actual_type'
5
-
6
- module Pact
7
- module Matchers
8
- describe UnixDiffFormatter do
9
-
10
- describe ".call" do
11
-
12
- let(:key_lines_count) { 4 }
13
- let(:colour) { false }
14
- subject { UnixDiffFormatter.call(diff, {colour: colour}) }
15
-
16
- let(:line_count) { subject.split("\n").size }
17
-
18
- context "when colour = false" do
19
- let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, "Joe" )}} }
20
- it "does not include colour" do
21
- expect(subject).to_not include("[0m")
22
- end
23
- end
24
-
25
- context "when colour = true" do
26
- let(:colour) { true }
27
- let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, "Joe" )}} }
28
- it "uses colour" do
29
- expect(subject).to include("[0m")
30
- end
31
- end
32
-
33
- context "with class based matching" do
34
- let(:diff) { {thing: TypeDifference.new(ExpectedType.new("fred"), ActualType.new(1))}}
35
- let(:output) { <<-EOF
36
- {
37
- - "thing": String
38
- + "thing": Fixnum
39
- }
40
- EOF
41
- }
42
-
43
- it "displays nicely" do
44
- expect(remove_ansicolor subject).to include output
45
- end
46
- end
47
-
48
- context "with an incorrect value in a hash" do
49
- let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, "Joe" )}} }
50
-
51
- it "displays '+' next to the unexpected value, and '-' next to the missing one" do
52
- expect(subject).to match /alligator/
53
- expect(subject).to match /\-.*Mary/
54
- expect(subject).to match /\+.*Joe/
55
- end
56
-
57
- it "generates the right number of lines, even with ActiveSupport loaded" do
58
- expect(line_count).to eq 9 + key_lines_count
59
- end
60
-
61
- end
62
-
63
- context "with an incorrect value in an array" do
64
- let(:diff) { [NoDiffIndicator.new, Difference.new({name: 'Mary'}, "Joe"), NoDiffIndicator.new] }
65
-
66
- it "displays '+' next to the incorrect values and '-' next to the missing ones" do
67
- expect(subject).to match /no difference here!/
68
- expect(subject).to match /\-.*{/
69
- expect(subject).to match /\-.*}/
70
- expect(subject).to match /\-.*Mary/
71
- expect(subject).to match /\+.*Joe/
72
- expect(subject).to match /no.*Mary.*Joe.*no/m
73
- end
74
-
75
- it "doesn't display the no difference indicator as a change" do
76
- expect(subject).to match(/^\s+no difference here!,$/)
77
- end
78
-
79
- it "generates the right number of lines, even with ActiveSupport loaded" do
80
- expect(line_count).to eq 9 + key_lines_count
81
- end
82
-
83
- end
84
-
85
- context "with a regular expression that was not matched" do
86
- let(:regexp) { %r{http://.*/thing/1234} }
87
- let(:diff) { {thing: RegexpDifference.new(regexp, "pear")} }
88
-
89
- it "displays the regular expression" do
90
- expect(subject).to include(regexp.inspect)
91
- expect(subject).to include(regexp.inspect)
92
- expect(subject).to match /\-.*thing/
93
- expect(subject).to match /\+.*pear/
94
- end
95
-
96
- it "does not put quotes around the regular expression" do
97
- expect(subject).to match /\/$/
98
- expect(subject).to match /: \//
99
- end
100
-
101
- it "generates the right number of lines, even with ActiveSupport loaded" do
102
- expect(line_count).to eq 5 + key_lines_count
103
- end
104
-
105
- end
106
-
107
- context "with a missing key" do
108
-
109
- let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, KeyNotFound.new )}} }
110
-
111
- it "it displays '-' next to the missing key and its value" do
112
- expect(subject).to match /\-.*{/
113
- expect(subject).to match /\-.*}/
114
- expect(subject).to match /\-.*alligator/
115
- expect(subject).to match /\-.*name/
116
- expect(subject).to match /\-.*Mary/
117
- end
118
-
119
- it "does not display the missing key in the actual output" do
120
- expect(subject).to_not match /\+.*alligator/
121
- end
122
-
123
- it "generates the right number of lines, even with ActiveSupport loaded" do
124
- expect(line_count).to eq 8 + key_lines_count
125
- end
126
- end
127
-
128
- context "with an unexpected key" do
129
- let(:diff) { {thing: {alligator: Difference.new(UnexpectedKey.new, {name: 'Mary'} )}} }
130
-
131
- it "displays '+' next to the unexpected key and its value" do
132
- expect(subject).to match /\+.*name/
133
- expect(subject).to match /\+.*Mary/
134
- expect(subject).to match /\+.*alligator/
135
- expect(subject).to match /\+.*}/
136
- expect(subject).to match /\+.*{/
137
- end
138
-
139
- it "does not display the unexpected key in the expected output" do
140
- expect(subject).to_not match /\-.*alligator/
141
- end
142
-
143
- it "generates the right number of lines, even with ActiveSupport loaded" do
144
- expect(line_count).to eq 8 + key_lines_count
145
- end
146
-
147
- end
148
-
149
- context "with a missing index" do
150
- let(:diff) { [NoDiffIndicator.new, Difference.new({name: 'Mary'}, IndexNotFound.new)] }
151
-
152
- it "displays '-' next to the missing items" do
153
- expect(subject).to match /\-.*Mary/
154
- expect(subject).to match /\-.*{/
155
- expect(subject).to match /\-.*}/
156
- end
157
-
158
- it "does not display IndexNotFound" do
159
- expect(subject).to_not match /#{IndexNotFound.new.to_s}/
160
- end
161
-
162
- it "generates the right number of lines, even with ActiveSupport loaded" do
163
- expect(line_count).to eq 8 + key_lines_count
164
- end
165
-
166
- end
167
-
168
- context "with an unexpected index" do
169
- let(:diff) { [NoDiffIndicator.new, Difference.new(UnexpectedIndex.new, {name: 'Mary'})] }
170
-
171
- it "displays '+' next to the unexpected item" do
172
- expect(subject).to match /\+.*{/
173
- expect(subject).to match /\+.*}/
174
- expect(subject).to match /\+.*name/
175
- expect(subject).to match /\+.*Mary/
176
- end
177
-
178
- xit "doesn't mark the 'no difference' as a change" do
179
- expect(subject).to match /#{NoDiffIndicator.new.to_s},/
180
- expect(subject).to_not match /\-.*#{NoDiffIndicator.new.to_s}/
181
- expect(subject).to_not match /\+.*#{NoDiffIndicator.new.to_s}/
182
- end
183
-
184
- it "does not display the UnexpectedIndex" do
185
- expect(subject).to_not match UnexpectedIndex.new.to_s
186
- end
187
-
188
- it "generates the right number of lines, even with ActiveSupport loaded" do
189
- expect(line_count).to eq 8 + key_lines_count
190
- end
191
-
192
- end
193
-
194
- context "with 2 unexpected indexes" do
195
- let(:diff) { [NoDiffIndicator.new, Difference.new(UnexpectedIndex.new, {name: 'Mary'}), Difference.new(UnexpectedIndex.new, {name: 'Joe'})] }
196
-
197
- it "displays '+' next to the unexpected item" do
198
- expect(subject).to match /\+.*Mary/
199
- expect(subject).to match /\+.*Joe/
200
- end
201
-
202
- it "does not display the UnexpectedIndex" do
203
- expect(subject).to_not match UnexpectedIndex.new.to_s
204
- end
205
-
206
- it "generates the right number of lines, even with ActiveSupport loaded" do
207
- expect(line_count).to eq 11 + key_lines_count
208
- end
209
-
210
- end
211
-
212
- end
213
-
214
- end
215
- end
216
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pact
4
- describe Reification do
5
-
6
- let(:response_spec) do
7
- {
8
- woot: /x/,
9
- britney: 'britney',
10
- nested: { foo: /bar/, baz: 'qux' },
11
- my_term: Term.new(generate: 'wiffle', matcher: /^wif/),
12
- array: ['first', /second/]
13
- }
14
- end
15
-
16
- describe "from term" do
17
-
18
- subject { Reification.from_term(response_spec) }
19
-
20
- it "converts regexes into real data" do
21
- expect(subject[:woot]).to eql 'x'
22
- end
23
-
24
- it "converts terms into real data" do
25
- expect(subject[:my_term]).to eql 'wiffle'
26
- end
27
-
28
- it "passes strings through" do
29
- expect(subject[:britney]).to eql 'britney'
30
- end
31
-
32
- it "handles nested hashes" do
33
- expect(subject[:nested]).to eql({ foo: 'bar', baz: 'qux' })
34
- end
35
-
36
- it "handles arrays" do
37
- expect(subject[:array]).to eql ['first', 'second']
38
- end
39
-
40
- end
41
-
42
- context "when reifying a Request" do
43
-
44
- let(:request){ Pact::Request::Expected.from_hash(method: 'get', path: '/', body: Pact::Term.new(generate: "sunny", matcher: /sun/))}
45
-
46
- subject { Reification.from_term(request) }
47
-
48
- it "turns it into a hash before reifying it" do
49
- expect(subject[:body]).to eq("sunny")
50
- end
51
-
52
- end
53
-
54
- context "when SomethingLike" do
55
-
56
- let(:request) { Pact::SomethingLike.new({a: 'String'})}
57
-
58
- subject { Reification.from_term(request)}
59
-
60
- it "returns the contents of the SomethingLike" do
61
- expect(subject).to eq({a: 'String'})
62
- end
63
-
64
- end
65
-
66
- end
67
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/dsl'
3
- require 'support/dsl_spec_support'
4
-
5
- module Pact
6
- describe DSL do
7
-
8
- class TestDSL
9
- extend DSL
10
- attr_accessor :thing, :blah, :global, :the_block, :another_block, :finalized
11
-
12
- dsl do
13
- def with_thing thing
14
- self.thing = thing
15
- end
16
- def with_blah blah
17
- self.blah = blah
18
- end
19
- def with_global global
20
- self.global = global
21
- end
22
-
23
- def with_block &the_block
24
- self.the_block = the_block
25
- end
26
-
27
- def with_another_block &the_block
28
- self.another_block = the_block
29
- end
30
-
31
- end
32
-
33
- def finalize
34
- @finalized = true
35
- end
36
- end
37
-
38
- describe "build" do
39
- before do
40
- def my_local_method
41
- 'LA LA LA'
42
- end
43
-
44
- my_local_var = 123
45
-
46
- local_app = "I'm a local app"
47
-
48
- @test = TestDSL.build do
49
- with_thing my_local_method
50
- with_blah my_local_var
51
- with_global global_method
52
- with_block do
53
- global_app
54
- end
55
- with_another_block do
56
- local_app
57
- end
58
- end
59
- end
60
-
61
- it "supports using a local variable" do
62
- expect(@test.blah).to eq 123
63
- end
64
-
65
- it "supports using a local method" do
66
- expect(@test.thing).to eq 'LA LA LA'
67
- end
68
-
69
- it "supports using global methods from other files" do
70
- expect(@test.global).to eq "I'm global"
71
- end
72
-
73
- it "supports using a local method to provide the app" do
74
- expect(@test.another_block.call).to eq("I'm a local app")
75
- end
76
-
77
- it "should support using a global method to provide the app but it doesn't" do
78
- expect(@test.the_block.call).to eq("I'm a global app")
79
- end
80
-
81
- it "calls finalize" do
82
- expect(@test.finalized).to be true
83
- end
84
- end
85
- end
86
- end