pact-mock_service 0.12.1 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 398fd7f11eaa7626bf0fad56bb01cc6e14af347e
4
- data.tar.gz: 401dc13f5eb8069e0142b024ed1ec17959793a12
3
+ metadata.gz: 502b6bb8fc1c02f95eb7cc9eceda437d070c14fd
4
+ data.tar.gz: 7899667f864724cf2dd32c35a914b21cb1fa670e
5
5
  SHA512:
6
- metadata.gz: b5fa971cae9bd4947f2f94b64e4b786eeb4e9f2e44ac3e8e1237ddcb1ab13cb7f2d9ebefd06f7a03da553013c45804e68dc5cb5141317c57ca8cb11415a32bc8
7
- data.tar.gz: f7aae06364aca5a81df5427afcf89a145bc5552f4eebe8db61812a52bbd76c5c2a01d3082ab4cfd2e3a5f94c51247137eb34e54d12010f0c839781646e8f4b95
6
+ metadata.gz: fd0da22f52dd902c8663a31e1a806cfc2bd86585b0cd8109b2158ad67732e3da0e5299723fdd358136c48f6ba4aab6c7d890b421f0d4be089a8936adbb9dbac0
7
+ data.tar.gz: 660b0087a8545dfcf910600649a27aeba7c7cdd991e2402e2455bfb411a8dafc7e3c1947c73085dbb0f8b82c5d77e8225efc693ebc9879f91e0eba34831c68dd
data/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@ Do this to generate your change history
2
2
 
3
3
  git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
4
4
 
5
+ * 18b98c0 - Included request matching rules in pact file (Matt Baumgartner, Wed Feb 15 16:20:50 2017 -0500)
6
+
5
7
  ### 0.12.1 (11 Jan 2017)
6
8
  * a0fbb02 - Upgrade Traveling Ruby to work on ruby 2.2.x (Matt Fellows, Tue Jan 10 22:57:32 2017 +1100)
7
9
 
@@ -20,7 +20,7 @@ module Pact
20
20
  hash[:query] = query if request.specified?(:query)
21
21
  hash[:headers] = headers if request.specified?(:headers)
22
22
  hash[:body] = body if request.specified?(:body)
23
- hash
23
+ include_matching_rules? ? with_matching_rules(hash) : hash
24
24
  end
25
25
 
26
26
  private
@@ -28,17 +28,32 @@ module Pact
28
28
  attr_reader :request
29
29
 
30
30
  def path
31
- Pact::Reification.from_term(request.path)
31
+ if include_matching_rules?
32
+ request.path
33
+ else
34
+ Pact::Reification.from_term(request.path)
35
+ end
32
36
  end
33
37
 
34
- def headers
35
- Pact::Reification.from_term(request.headers)
38
+ def query
39
+ if include_matching_rules?
40
+ request.query.query.each do | key, val |
41
+ if val.length == 1
42
+ request.query.query[key] = val[0]
43
+ end
44
+ end
45
+ request.query.query
46
+ else
47
+ Pact::Reification.from_term(request.query)
48
+ end
36
49
  end
37
50
 
38
- # This feels wrong to be checking the class type of the Query
39
- # Do this better somehow.
40
- def query
41
- Pact::Reification.from_term(request.query)
51
+ def headers
52
+ if include_matching_rules?
53
+ request.headers
54
+ else
55
+ Pact::Reification.from_term(request.headers)
56
+ end
42
57
  end
43
58
 
44
59
  # This feels wrong to be checking the class type of the body
@@ -47,7 +62,11 @@ module Pact
47
62
  if content_type_is_form && request.body.is_a?(Hash)
48
63
  URI.encode_www_form convert_hash_body_to_array_of_arrays
49
64
  else
50
- Pact::Reification.from_term(request.body)
65
+ if include_matching_rules?
66
+ request.body
67
+ else
68
+ Pact::Reification.from_term(request.body)
69
+ end
51
70
  end
52
71
  end
53
72
 
@@ -63,8 +82,28 @@ module Pact
63
82
  arrays << [key, value]
64
83
  end
65
84
  end
66
- Pact::Reification.from_term arrays
85
+
86
+ if include_matching_rules?
87
+ arrays
88
+ else
89
+ Pact::Reification.from_term(arrays)
90
+ end
91
+ end
92
+
93
+ def include_matching_rules?
94
+ pact_specification_version && !pact_specification_version.start_with?('1')
95
+ end
96
+
97
+ def with_matching_rules hash
98
+ matching_rules = Pact::MatchingRules.extract hash
99
+ example = Pact::Reification.from_term hash
100
+ return example if matching_rules.empty?
101
+ example.merge(matchingRules: matching_rules)
102
+ end
103
+
104
+ def pact_specification_version
105
+ @decorator_options[:pact_specification_version]
67
106
  end
68
107
 
69
108
  end
70
- end
109
+ end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "0.12.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-mock_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-01-10 00:00:00.000000000 Z
15
+ date: 2017-04-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
331
  version: '0'
332
332
  requirements: []
333
333
  rubyforge_project:
334
- rubygems_version: 2.5.1
334
+ rubygems_version: 2.4.5
335
335
  signing_key:
336
336
  specification_version: 4
337
337
  summary: Provides a mock service for use with Pact