pact 1.0.36 → 1.0.37
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/pact/provider/rspec.rb +22 -14
- data/lib/pact/provider/state/provider_state.rb +11 -2
- data/lib/pact/version.rb +1 -1
- data/spec/support/stubbing_using_allow.rb +7 -4
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
git log --date=relative --pretty=format:' * %h - %s (%an, %ad)'
|
4
4
|
|
5
|
+
### 1.0.37 (19 March 2014)
|
6
|
+
|
7
|
+
* 0e8b80e - Cleaned up pact:verify rspec matcher lines so the output makes more sense to the reader (bethesque, 3 minutes ago)
|
8
|
+
* 03e5ea3 - Fixed config.include to ensure ordering of config and provider state declarations does not matter (bethesque, 20 minutes ago)
|
9
|
+
|
5
10
|
### 1.0.36 (19 March 2014)
|
6
11
|
|
7
12
|
* c28de11 - Added patch level to pactSpecificationVersion (bethesque, 37 seconds ago)
|
data/Gemfile.lock
CHANGED
data/lib/pact/provider/rspec.rb
CHANGED
@@ -83,28 +83,36 @@ module Pact
|
|
83
83
|
|
84
84
|
end
|
85
85
|
|
86
|
-
def describe_response
|
87
|
-
|
86
|
+
def describe_response expected_response, interaction_context
|
87
|
+
|
88
88
|
describe "returns a response which" do
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
|
90
|
+
let(:expected_response_status) { expected_response['status'] }
|
91
|
+
let(:expected_response_body) { expected_response['body'] }
|
92
|
+
let(:response) { interaction_context.last_response }
|
93
|
+
let(:response_status) { response.status }
|
94
|
+
let(:response_body) { parse_body_from_response(response) }
|
95
|
+
|
96
|
+
if expected_response['status']
|
97
|
+
it "has status code #{expected_response['status']}" do
|
98
|
+
expect(response_status).to eql expected_response_status
|
92
99
|
end
|
93
100
|
end
|
94
101
|
|
95
|
-
if
|
102
|
+
if expected_response['headers']
|
96
103
|
describe "includes headers" do
|
97
|
-
|
98
|
-
it "\"#{name}\" with value \"#{
|
99
|
-
|
104
|
+
expected_response['headers'].each do |name, expected_header_value|
|
105
|
+
it "\"#{name}\" with value \"#{expected_header_value}\"" do
|
106
|
+
header_value = response.headers[name]
|
107
|
+
expect(header_value).to match_term expected_header_value
|
100
108
|
end
|
101
109
|
end
|
102
110
|
end
|
103
111
|
end
|
104
112
|
|
105
|
-
if
|
113
|
+
if expected_response['body']
|
106
114
|
it "has a matching body" do
|
107
|
-
expect(
|
115
|
+
expect(response_body).to match_term expected_response_body
|
108
116
|
end
|
109
117
|
end
|
110
118
|
end
|
@@ -135,10 +143,10 @@ module Pact
|
|
135
143
|
@already_run = []
|
136
144
|
end
|
137
145
|
|
138
|
-
def run_once
|
139
|
-
unless @already_run.include?(
|
146
|
+
def run_once hook
|
147
|
+
unless @already_run.include?(hook)
|
140
148
|
yield
|
141
|
-
@already_run <<
|
149
|
+
@already_run << hook
|
142
150
|
end
|
143
151
|
end
|
144
152
|
|
@@ -77,8 +77,6 @@ module Pact
|
|
77
77
|
@set_up_defined = false
|
78
78
|
@tear_down_defined = false
|
79
79
|
@no_op_defined = false
|
80
|
-
#not sure why but using include doesn't bring in the configured module methods
|
81
|
-
self.extend ProviderStateConfiguredModules
|
82
80
|
end
|
83
81
|
|
84
82
|
dsl do
|
@@ -120,12 +118,14 @@ module Pact
|
|
120
118
|
|
121
119
|
def set_up
|
122
120
|
if @set_up_block
|
121
|
+
include_provider_state_configured_modules
|
123
122
|
instance_eval &@set_up_block
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
126
|
def tear_down
|
128
127
|
if @tear_down_block
|
128
|
+
include_provider_state_configured_modules
|
129
129
|
instance_eval &@tear_down_block
|
130
130
|
end
|
131
131
|
end
|
@@ -155,6 +155,15 @@ module Pact
|
|
155
155
|
"#{namespace}.#{name}"
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
def include_provider_state_configured_modules
|
160
|
+
# Doing this at runtime means the order of the Pact configuration block
|
161
|
+
# and the provider state declarations doesn't matter.
|
162
|
+
# Using include ProviderStateConfiguredModules on the class doesn't seem to work -
|
163
|
+
# modules dynamically added to ProviderStateConfiguredModules don't seem to be
|
164
|
+
# included in the including class.
|
165
|
+
self.extend(ProviderStateConfiguredModules) unless self.singleton_class.ancestors.include?(ProviderStateConfiguredModules)
|
166
|
+
end
|
158
167
|
end
|
159
168
|
|
160
169
|
class NoOpProviderState
|
data/lib/pact/version.rb
CHANGED
@@ -12,10 +12,6 @@ class App
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
Pact.configure do | config |
|
16
|
-
config.include RSpec::Mocks::ExampleMethods
|
17
|
-
end
|
18
|
-
|
19
15
|
Pact.provider_states_for 'Consumer' do
|
20
16
|
provider_state 'something is stubbed' do
|
21
17
|
set_up do
|
@@ -24,6 +20,13 @@ Pact.provider_states_for 'Consumer' do
|
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
23
|
+
# Include the ExampleMethods module after the provider states are declared
|
24
|
+
# to ensure the ordering doesn't matter
|
25
|
+
|
26
|
+
Pact.configure do | config |
|
27
|
+
config.include RSpec::Mocks::ExampleMethods
|
28
|
+
end
|
29
|
+
|
27
30
|
Pact.service_provider 'Provider' do
|
28
31
|
app { App }
|
29
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.37
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -455,7 +455,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
455
455
|
version: '0'
|
456
456
|
segments:
|
457
457
|
- 0
|
458
|
-
hash:
|
458
|
+
hash: 1047822279614111936
|
459
459
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
460
460
|
none: false
|
461
461
|
requirements:
|
@@ -464,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
464
464
|
version: '0'
|
465
465
|
segments:
|
466
466
|
- 0
|
467
|
-
hash:
|
467
|
+
hash: 1047822279614111936
|
468
468
|
requirements: []
|
469
469
|
rubyforge_project:
|
470
470
|
rubygems_version: 1.8.23
|