pact-mock_service 0.1.0 → 0.2.0

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: d4d778c67c786242b411bfeb2ea68de4d8a8ba02
4
- data.tar.gz: be3a2b3caab987b807e6844f35311450e51b5a7f
3
+ metadata.gz: 3675552ba3caef160721edfcd17ebaea904b60da
4
+ data.tar.gz: 21c7f09e8cd25570599d26519f76caab79df59de
5
5
  SHA512:
6
- metadata.gz: 77f56fc00125a93dc33d68e7ec16c1355393fa05f30b89df2370000b794ebe0d6a245d11c35476155c1934f29a09df1b7aec9a5e772996919d4573df6f9702d0
7
- data.tar.gz: b3b60e97d6553ce8318bbe71e76c681263fed8598fe5cf22e25db38a0be6ac1704c4cad12ef7f169706b8d9e8ddfd5727a12eff13d6e55ca8bddf247e6d92ff8
6
+ metadata.gz: 6433bb82c9702192c88e4b0b107c93a03b2985d3efaf6e54b1e2b7969016df264dbc5601f5c3fe87c8c0d709ba715bade1c52726016c557ec30ce8d0d5a61093
7
+ data.tar.gz: ab60286205a9b24ded877e33359b5622a8c66ac7b231e90688cf00010cd4c08a078204011dcdb9c8fb6f0cdb04ffb35b79a0c93f97b3c0acafa8fb92d3bca5b2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@ Do this to generate your change history
2
2
 
3
3
  git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ ### 0.2.0 (24 October 2014)
6
+
7
+ * d071e2c - Added field to /pact request body to specify the pact directory (Beth, Fri Oct 24 09:22:06 2014 +1100)
8
+
5
9
  ### 0.1.0 (22 October 2014)
6
10
 
7
11
  * 62caf8e - Removed Gemfile.lock from git (bethesque, Wed Oct 22 13:07:54 2014 +1100)
@@ -7,6 +7,8 @@ require 'pact/shared/active_support_support'
7
7
 
8
8
  module Pact
9
9
 
10
+ class ConsumerContractWriterError < StandardError; end
11
+
10
12
  class ConsumerContractWriter
11
13
 
12
14
  include Pact::FileName
@@ -38,7 +40,7 @@ module Pact
38
40
 
39
41
  def pactfile_path
40
42
  raise 'You must specify a consumer and provider name' unless (consumer_name && provider_name)
41
- file_path consumer_name, provider_name, Pact.configuration.pact_dir
43
+ file_path consumer_name, provider_name, pact_dir
42
44
  end
43
45
 
44
46
  def update_pactfile
@@ -112,6 +114,13 @@ module Pact
112
114
  def provider_name
113
115
  consumer_contract_details[:provider][:name]
114
116
  end
117
+
118
+ def pact_dir
119
+ unless consumer_contract_details[:pact_dir]
120
+ raise ConsumerContractWriterError.new("Please indicate the directory to write the pact to by specifying the pact_dir field")
121
+ end
122
+ consumer_contract_details[:pact_dir]
123
+ end
115
124
  end
116
125
 
117
126
  end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -8,26 +8,27 @@ module Pact
8
8
  let(:support_pact_file) { './spec/support/a_consumer-a_provider.json' }
9
9
  let(:consumer_name) { 'a consumer' }
10
10
  let(:provider_name) { 'a provider' }
11
+ let(:target_pact_file_location) { "#{tmp_pact_dir}/a_consumer-a_provider.json" }
11
12
 
12
13
  before do
13
14
  Pact.clear_configuration
14
- allow(Pact.configuration).to receive(:pact_dir).and_return(File.expand_path(tmp_pact_dir))
15
15
  FileUtils.rm_rf tmp_pact_dir
16
16
  FileUtils.mkdir_p tmp_pact_dir
17
- FileUtils.cp support_pact_file, "#{tmp_pact_dir}/a_consumer-a_provider.json"
17
+ FileUtils.cp support_pact_file, target_pact_file_location
18
18
  end
19
19
 
20
20
  let(:existing_interactions) { ConsumerContract.from_json(File.read(support_pact_file)).interactions }
21
21
  let(:new_interactions) { [InteractionFactory.create] }
22
- let(:tmp_pact_dir) {"./tmp/pacts"}
22
+ let(:tmp_pact_dir) { "./tmp/pacts" }
23
23
  let(:logger) { double("logger").as_null_object }
24
- let(:pactfile_write_mode) {:overwrite}
24
+ let(:pactfile_write_mode) { :overwrite }
25
25
  let(:consumer_contract_details) {
26
26
  {
27
- consumer: {name: consumer_name},
28
- provider: {name: provider_name},
27
+ consumer: { name: consumer_name },
28
+ provider: { name: provider_name },
29
29
  pactfile_write_mode: pactfile_write_mode,
30
- interactions: new_interactions
30
+ interactions: new_interactions,
31
+ pact_dir: tmp_pact_dir
31
32
  }
32
33
  }
33
34
 
@@ -99,10 +100,26 @@ module Pact
99
100
  end
100
101
  end
101
102
 
102
- describe "write" do
103
- it "writes the pact file, this is a useless test" do
104
- expect_any_instance_of(ConsumerContractWriter).to receive(:update_pactfile)
103
+ describe "#write" do
104
+ it "writes the pact file to the pact_dir" do
105
+ FileUtils.rm_rf target_pact_file_location
105
106
  consumer_contract_writer.write
107
+ expect(File.exist?(target_pact_file_location)).to be true
108
+ end
109
+
110
+ context "when the pact_dir is not specified" do
111
+ let(:consumer_contract_details) {
112
+ {
113
+ consumer: { name: consumer_name },
114
+ provider: { name: provider_name },
115
+ pactfile_write_mode: pactfile_write_mode,
116
+ interactions: new_interactions
117
+ }
118
+ }
119
+
120
+ it "raises an error" do
121
+ expect{ consumer_contract_writer.write }.to raise_error ConsumerContractWriterError, /Please indicate the directory/
122
+ end
106
123
  end
107
124
  end
108
125
 
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,244 +12,244 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-10-22 00:00:00.000000000 Z
15
+ date: 2014-10-23 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - '>='
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: '0'
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'
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: find_a_port
47
47
  requirement: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - ~>
49
+ - - "~>"
50
50
  - !ruby/object:Gem::Version
51
51
  version: 1.0.1
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: 1.0.1
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rack-test
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - ~>
63
+ - - "~>"
64
64
  - !ruby/object:Gem::Version
65
65
  version: 0.6.2
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: 0.6.2
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: awesome_print
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ~>
77
+ - - "~>"
78
78
  - !ruby/object:Gem::Version
79
79
  version: '1.1'
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: '1.1'
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: thor
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - '>='
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: '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: '0'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: json
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - '>='
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
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: '0'
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: webrick
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: term-ansicolor
131
131
  requirement: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - ~>
133
+ - - "~>"
134
134
  - !ruby/object:Gem::Version
135
135
  version: '1.0'
136
136
  type: :runtime
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: '1.0'
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: pact-support
145
145
  requirement: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - ~>
147
+ - - "~>"
148
148
  - !ruby/object:Gem::Version
149
149
  version: 0.1.1
150
150
  type: :runtime
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: 0.1.1
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rake
159
159
  requirement: !ruby/object:Gem::Requirement
160
160
  requirements:
161
- - - ~>
161
+ - - "~>"
162
162
  - !ruby/object:Gem::Version
163
163
  version: 10.0.3
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: 10.0.3
171
171
  - !ruby/object:Gem::Dependency
172
172
  name: webmock
173
173
  requirement: !ruby/object:Gem::Requirement
174
174
  requirements:
175
- - - ~>
175
+ - - "~>"
176
176
  - !ruby/object:Gem::Version
177
177
  version: 1.18.0
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: 1.18.0
185
185
  - !ruby/object:Gem::Dependency
186
186
  name: pry
187
187
  requirement: !ruby/object:Gem::Requirement
188
188
  requirements:
189
- - - '>='
189
+ - - ">="
190
190
  - !ruby/object:Gem::Version
191
191
  version: '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: '0'
199
199
  - !ruby/object:Gem::Dependency
200
200
  name: fakefs
201
201
  requirement: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - ~>
203
+ - - "~>"
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0.4'
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.4'
213
213
  - !ruby/object:Gem::Dependency
214
214
  name: hashie
215
215
  requirement: !ruby/object:Gem::Requirement
216
216
  requirements:
217
- - - ~>
217
+ - - "~>"
218
218
  - !ruby/object:Gem::Version
219
219
  version: '2.0'
220
220
  type: :development
221
221
  prerelease: false
222
222
  version_requirements: !ruby/object:Gem::Requirement
223
223
  requirements:
224
- - - ~>
224
+ - - "~>"
225
225
  - !ruby/object:Gem::Version
226
226
  version: '2.0'
227
227
  - !ruby/object:Gem::Dependency
228
228
  name: activesupport
229
229
  requirement: !ruby/object:Gem::Requirement
230
230
  requirements:
231
- - - '>='
231
+ - - ">="
232
232
  - !ruby/object:Gem::Version
233
233
  version: '0'
234
234
  type: :development
235
235
  prerelease: false
236
236
  version_requirements: !ruby/object:Gem::Requirement
237
237
  requirements:
238
- - - '>='
238
+ - - ">="
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  - !ruby/object:Gem::Dependency
242
242
  name: faraday
243
243
  requirement: !ruby/object:Gem::Requirement
244
244
  requirements:
245
- - - '>='
245
+ - - ">="
246
246
  - !ruby/object:Gem::Version
247
247
  version: '0'
248
248
  type: :development
249
249
  prerelease: false
250
250
  version_requirements: !ruby/object:Gem::Requirement
251
251
  requirements:
252
- - - '>='
252
+ - - ">="
253
253
  - !ruby/object:Gem::Version
254
254
  version: '0'
255
255
  description:
@@ -264,9 +264,9 @@ executables:
264
264
  extensions: []
265
265
  extra_rdoc_files: []
266
266
  files:
267
- - .gitignore
268
- - .rspec
269
- - .travis.yml
267
+ - ".gitignore"
268
+ - ".rspec"
269
+ - ".travis.yml"
270
270
  - CHANGELOG.md
271
271
  - Gemfile
272
272
  - LICENSE.txt
@@ -356,17 +356,17 @@ require_paths:
356
356
  - lib
357
357
  required_ruby_version: !ruby/object:Gem::Requirement
358
358
  requirements:
359
- - - '>='
359
+ - - ">="
360
360
  - !ruby/object:Gem::Version
361
361
  version: '0'
362
362
  required_rubygems_version: !ruby/object:Gem::Requirement
363
363
  requirements:
364
- - - '>='
364
+ - - ">="
365
365
  - !ruby/object:Gem::Version
366
366
  version: '0'
367
367
  requirements: []
368
368
  rubyforge_project:
369
- rubygems_version: 2.0.14
369
+ rubygems_version: 2.2.2
370
370
  signing_key:
371
371
  specification_version: 4
372
372
  summary: Provides a mock service for use with Pact