pact-support 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4363cf97810f093eaefcfdc2fb89e1bbc073f695
4
- data.tar.gz: 8e5bfdb3ef4122179865b7a267e570145b644f04
3
+ metadata.gz: e910cf32ae5812de2e20eb59b3e5ca000f4bb993
4
+ data.tar.gz: c075489026ea2c5b501c673d085bf0ffe27434a1
5
5
  SHA512:
6
- metadata.gz: d35a47659cc146ee79b06f7c63e479ac9b942e2133e0f67d863f8a0d1f55159494406bed0f494a8507b7350b7351b765c8a52e4ca277f00f68d905b9bfe1d4b5
7
- data.tar.gz: cfcb7b67e4945b8e32c00d1131232b28a3cb1e748a13617503dcfa7d57764029bbb83da6e1be300196066b95cfc8a2276c06ea0fd250adab9bc10d0bb0c3097c
6
+ metadata.gz: 06989f174ace83fa1ccccf4ea8bdad96d188a0899706aef0f7bed147eb86682644ed08457f6974a01e2e5abfd425c01f0787d2bbd4f73e9d9258cea1a3c1d7b7
7
+ data.tar.gz: 7d3bb57ae30029fd219bf1f54fc1fe7f471940365f4431f5f11b20d18ae67470729a648a41191d1daf799f63b78485ce913d22497a776b8a799fdbecc4823739
@@ -2,6 +2,15 @@ Do this to generate your change history
2
2
 
3
3
  git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ ### 0.2.1 (21 January 2015)
6
+
7
+ * 4e26c75 - Ignore HTTP method case when determining if routes match. https://github.com/bethesque/pact-support/issues/3 (Beth, Tue Jan 20 20:15:20 2015 +1100)
8
+ * af96eba - Allow request path to be a Pact::Term (Beth, Tue Jan 20 19:37:23 2015 +1100)
9
+
10
+ ### 0.1.4 (20 January 2015)
11
+
12
+ A naughty release because bumping the minor version to 0.2.0 means I have to upgrade all the gems.
13
+
5
14
  ### 0.2.0 (20 January 2015)
6
15
 
7
16
  * bb5d893 - Added option to UnixDiffFormatter to not show the explanation (Beth, Tue Jan 20 08:39:42 2015 +1100)
@@ -31,7 +31,9 @@ module Pact
31
31
  end
32
32
 
33
33
  def matches_route? actual_request
34
- diff({:method => method, :path => path}, {:method => actual_request.method, :path => actual_request.path}).empty?
34
+ route = {:method => method.upcase, :path => path}
35
+ other_route = {:method => actual_request.method.upcase, :path => actual_request.path}
36
+ diff(route, other_route).empty?
35
37
  end
36
38
 
37
39
  def difference(actual_request)
@@ -16,7 +16,7 @@ module Pact
16
16
 
17
17
  def initialize(method, path, headers, body, query)
18
18
  @method = method.to_s
19
- @path = path.chomp('/')
19
+ @path = path.respond_to?(:chomp) ? path.chomp('/') : path #TODO get rid of the chomp in v2
20
20
  @headers = Hash === headers ? Headers.new(headers) : headers # Could be a NullExpectation - TODO make this more elegant
21
21
  @body = body
22
22
  @query = is_unspecified?(query) ? query : Pact::Query.create(query)
@@ -27,10 +27,9 @@ module Pact
27
27
  method: method,
28
28
  path: path,
29
29
  }
30
-
31
- hash.merge!(query: query) if specified?(:query)
32
- hash.merge!(headers: headers) if specified?(:headers)
33
- hash.merge!(body: body) if specified?(:body)
30
+ hash[:query] = query if specified?(:query)
31
+ hash[:headers] = headers if specified?(:headers)
32
+ hash[:body] = body if specified?(:body)
34
33
  hash
35
34
  end
36
35
 
@@ -79,14 +78,17 @@ module Pact
79
78
  end
80
79
 
81
80
  def to_hash_without_body_or_query
82
- keep_keys = [:method, :path, :headers]
83
- to_hash.reject{ |key, value| !keep_keys.include? key }.tap do | hash |
84
- hash[:method] = method.upcase
85
- end
81
+ hash = {
82
+ method: method.upcase,
83
+ path: path
84
+ }
85
+ hash[:headers] = headers if specified?(:headers)
86
+ hash
86
87
  end
87
88
 
88
89
  def display_path
89
- path.empty? ? "/" : path
90
+ reified_path = Pact::Reification.from_term(path)
91
+ reified_path.empty? ? "/" : reified_path
90
92
  end
91
93
 
92
94
  def display_query
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -24,6 +24,16 @@ module Pact
24
24
  expect(subject == other).to be false
25
25
  end
26
26
  end
27
+ context "with a SomethingLike" do
28
+ let(:response) { {body: {age: SomethingLike.new(20)} } }
29
+ let(:other_response) { {body: {age: SomethingLike.new(20)} } }
30
+ let(:other) { InteractionFactory.create(response: other_response) }
31
+ subject { InteractionFactory.create response: response }
32
+
33
+ it "returns true" do
34
+ expect(subject == other).to be true
35
+ end
36
+ end
27
37
  end
28
38
 
29
39
  describe "matches_criteria?" do
@@ -26,6 +26,26 @@ module Pact
26
26
  end
27
27
  end
28
28
 
29
+ describe "matches_route?" do
30
+ context "when the case of the method is different but the path is the same" do
31
+ subject { Request::Expected.from_hash(method: 'get', path: '/') }
32
+ let(:other) { Consumer::Request::Actual.from_hash(method: 'get', path: '/', query: nil, headers: {}) }
33
+
34
+ it "returns true" do
35
+ expect(subject.matches_route?(other)).to be true
36
+ end
37
+ end
38
+
39
+ context "when the path is a Pact::Term" do
40
+ subject { Request::Expected.from_hash(method: 'get', path: Pact::Term.new(matcher: %r{/alligators/.*}, generate: '/alligators/Mary')) }
41
+ let(:other) { Consumer::Request::Actual.from_hash(method: 'get', path: '/alligators/John', query: nil, headers: {}) }
42
+
43
+ it "returns true" do
44
+ expect(subject.matches_route?(other)).to be true
45
+ end
46
+ end
47
+ end
48
+
29
49
  describe "matching to actual requests" do
30
50
 
31
51
  subject { Request::Expected.new(expected_method, expected_path, expected_headers, expected_body, expected_query, options) }
@@ -398,8 +418,6 @@ module Pact
398
418
  end
399
419
  end
400
420
 
401
-
402
-
403
421
  context "when in the body a string is expected, but a number is found" do
404
422
  let(:actual_body) { { thing: 123} }
405
423
  let(:expected_body) { { thing: "123" } }
@@ -67,6 +67,14 @@ module Pact
67
67
  end
68
68
  end
69
69
 
70
+ context "with a Pact::Term for the path" do
71
+ subject { TestRequest.new("get", Pact::Term.new(matcher: /a/, generate: '/apple'), {}, {} , "").method_and_path }
72
+
73
+ it "uses the generate value" do
74
+ expect(subject).to eq("GET /apple")
75
+ end
76
+ end
77
+
70
78
  context "with a path" do
71
79
  subject { TestRequest.new("get", "/something", {}, {} , "").method_and_path }
72
80
 
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Pact
4
4
  describe SomethingLike do
5
+
5
6
  describe 'json_create' do
6
7
  let(:json) do
7
8
  '
@@ -11,11 +12,12 @@ module Pact
11
12
  }
12
13
  '
13
14
  end
15
+
14
16
  subject { SomethingLike.json_create(JSON.parse(json)) }
17
+
15
18
  it "creates a SomethingLike object from json" do
16
19
  expect(subject).to eq(SomethingLike.new({"thing" => "blah"}))
17
20
  end
18
21
  end
19
22
  end
20
-
21
- end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,202 +12,202 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-01-19 00:00:00.000000000 Z
15
+ date: 2015-01-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - "~>"
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.1.7
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - "~>"
28
+ - - ~>
29
29
  - !ruby/object:Gem::Version
30
30
  version: 0.1.7
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rspec
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - ">="
35
+ - - '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '2.14'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ">="
42
+ - - '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: '2.14'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: rack-test
47
47
  requirement: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - "~>"
49
+ - - ~>
50
50
  - !ruby/object:Gem::Version
51
51
  version: 0.6.2
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - "~>"
56
+ - - ~>
57
57
  - !ruby/object:Gem::Version
58
58
  version: 0.6.2
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: awesome_print
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - "~>"
63
+ - - ~>
64
64
  - !ruby/object:Gem::Version
65
65
  version: '1.1'
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - "~>"
70
+ - - ~>
71
71
  - !ruby/object:Gem::Version
72
72
  version: '1.1'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: json
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ">="
77
+ - - '>='
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  type: :runtime
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ">="
84
+ - - '>='
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: term-ansicolor
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - "~>"
91
+ - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: '1.0'
94
94
  type: :runtime
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - "~>"
98
+ - - ~>
99
99
  - !ruby/object:Gem::Version
100
100
  version: '1.0'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: find_a_port
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - "~>"
105
+ - - ~>
106
106
  - !ruby/object:Gem::Version
107
107
  version: 1.0.1
108
108
  type: :runtime
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - "~>"
112
+ - - ~>
113
113
  - !ruby/object:Gem::Version
114
114
  version: 1.0.1
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: thor
117
117
  requirement: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - ">="
119
+ - - '>='
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  type: :runtime
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">="
126
+ - - '>='
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  - !ruby/object:Gem::Dependency
130
130
  name: rake
131
131
  requirement: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - "~>"
133
+ - - ~>
134
134
  - !ruby/object:Gem::Version
135
135
  version: 10.0.3
136
136
  type: :development
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
- - - "~>"
140
+ - - ~>
141
141
  - !ruby/object:Gem::Version
142
142
  version: 10.0.3
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: webmock
145
145
  requirement: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - "~>"
147
+ - - ~>
148
148
  - !ruby/object:Gem::Version
149
149
  version: 1.18.0
150
150
  type: :development
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
153
153
  requirements:
154
- - - "~>"
154
+ - - ~>
155
155
  - !ruby/object:Gem::Version
156
156
  version: 1.18.0
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: pry
159
159
  requirement: !ruby/object:Gem::Requirement
160
160
  requirements:
161
- - - ">="
161
+ - - '>='
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  type: :development
165
165
  prerelease: false
166
166
  version_requirements: !ruby/object:Gem::Requirement
167
167
  requirements:
168
- - - ">="
168
+ - - '>='
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  - !ruby/object:Gem::Dependency
172
172
  name: fakefs
173
173
  requirement: !ruby/object:Gem::Requirement
174
174
  requirements:
175
- - - "~>"
175
+ - - ~>
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0.4'
178
178
  type: :development
179
179
  prerelease: false
180
180
  version_requirements: !ruby/object:Gem::Requirement
181
181
  requirements:
182
- - - "~>"
182
+ - - ~>
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0.4'
185
185
  - !ruby/object:Gem::Dependency
186
186
  name: hashie
187
187
  requirement: !ruby/object:Gem::Requirement
188
188
  requirements:
189
- - - "~>"
189
+ - - ~>
190
190
  - !ruby/object:Gem::Version
191
191
  version: '2.0'
192
192
  type: :development
193
193
  prerelease: false
194
194
  version_requirements: !ruby/object:Gem::Requirement
195
195
  requirements:
196
- - - "~>"
196
+ - - ~>
197
197
  - !ruby/object:Gem::Version
198
198
  version: '2.0'
199
199
  - !ruby/object:Gem::Dependency
200
200
  name: activesupport
201
201
  requirement: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - ">="
203
+ - - '>='
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
206
  type: :development
207
207
  prerelease: false
208
208
  version_requirements: !ruby/object:Gem::Requirement
209
209
  requirements:
210
- - - ">="
210
+ - - '>='
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  description:
@@ -221,9 +221,9 @@ executables: []
221
221
  extensions: []
222
222
  extra_rdoc_files: []
223
223
  files:
224
- - ".gitignore"
225
- - ".rspec"
226
- - ".travis.yml"
224
+ - .gitignore
225
+ - .rspec
226
+ - .travis.yml
227
227
  - CHANGELOG.md
228
228
  - Gemfile
229
229
  - LICENSE.txt
@@ -344,17 +344,17 @@ require_paths:
344
344
  - lib
345
345
  required_ruby_version: !ruby/object:Gem::Requirement
346
346
  requirements:
347
- - - ">="
347
+ - - '>='
348
348
  - !ruby/object:Gem::Version
349
349
  version: '0'
350
350
  required_rubygems_version: !ruby/object:Gem::Requirement
351
351
  requirements:
352
- - - ">="
352
+ - - '>='
353
353
  - !ruby/object:Gem::Version
354
354
  version: '0'
355
355
  requirements: []
356
356
  rubyforge_project:
357
- rubygems_version: 2.2.2
357
+ rubygems_version: 2.0.14
358
358
  signing_key:
359
359
  specification_version: 4
360
360
  summary: Shared code for Pact gems
@@ -412,4 +412,3 @@ test_files:
412
412
  - spec/support/test_app_fail.json
413
413
  - spec/support/test_app_pass.json
414
414
  - spec/support/test_app_with_right_content_type_differ.json
415
- has_rdoc: