pact 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -0
- data/LICENSE.txt +3 -2
- data/lib/pact/cli.rb +12 -1
- data/lib/pact/cli/generate_pact_docs.rb +4 -0
- data/lib/pact/consumer.rb +0 -3
- data/lib/pact/consumer/configuration/configuration_extensions.rb +5 -1
- data/lib/pact/consumer/configuration/mock_service.rb +12 -3
- data/lib/pact/consumer/configuration/service_consumer.rb +1 -1
- data/lib/pact/consumer/consumer_contract_builder.rb +2 -2
- data/lib/pact/consumer/spec_hooks.rb +7 -5
- data/lib/pact/doc/README.md +13 -0
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +2 -2
- metadata +10 -8
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,17 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
git log --pretty=format:' * %h - %s (%an, %ad)'
|
4
4
|
|
5
|
+
### 1.6.0 (17 February 2015)
|
6
|
+
|
7
|
+
* 03a71f7 - Added specs for 'pact docs' CLI, and changed defaults to standard Pact configuration defaults (Beth Skurrie, Tue Feb 17 21:25:50 2015 +1100)
|
8
|
+
* 8e0deba - Pact CLI docs feature basic implementation (Daniel Stankevich, Tue Feb 17 20:27:21 2015 +1100)
|
9
|
+
* 0e0e3f2 - Added pact_specification_version to the service provider DSL. Upgraded to pact-mock_service 0.4.0 to support this option. (Beth Skurrie, Fri Feb 13 17:53:31 2015 +1100)
|
10
|
+
* c8c58cd - minor readme updates to help with clarity :memo: (Joe Sustaric, Thu Feb 12 11:13:21 2015 +1100)
|
11
|
+
* dda3c5e - Expose ability to add more than one doc generator (Beth Skurrie, Wed Feb 11 09:50:48 2015 +1100)
|
12
|
+
* ada2231 - Upgrading to version 0.3.0 of pact-mock_service (Beth Skurrie, Wed Feb 4 19:41:10 2015 +1100)
|
13
|
+
* f34c1de - Whitespace change to LICENSE.txt so I can add a comment to indicate that the previous commit to LICENSE.txt was made because Mike Rowe requested it, as he was auditing REA's use of open source software. (Beth Skurrie, Mon Feb 2 17:05:13 2015 +1100)
|
14
|
+
* ff98558 - Update LICENSE.txt (Beth Skurrie, Mon Feb 2 16:59:14 2015 +1100)
|
15
|
+
|
5
16
|
### 1.5.0 (25 November 2014)
|
6
17
|
|
7
18
|
* 9a5ab1c - Allow path to be specified as a Pact::Term (Beth, Wed Jan 21 07:56:19 2015 +1100)
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2013
|
1
|
+
Copyright (c) 2013 REA Group Ltd
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,5 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/lib/pact/cli.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'pact/
|
2
|
+
require 'pact/consumer/configuration'
|
3
3
|
|
4
4
|
module Pact
|
5
5
|
class CLI < Thor
|
@@ -12,8 +12,19 @@ module Pact
|
|
12
12
|
method_option :provider_state, aliases: "-s", desc: "Provider state filter"
|
13
13
|
|
14
14
|
def verify
|
15
|
+
require 'pact/cli/run_pact_verification'
|
15
16
|
Cli::RunPactVerification.call(options)
|
16
17
|
end
|
17
18
|
|
19
|
+
desc 'docs', "Generate Pact documentation in markdown"
|
20
|
+
method_option :pact_dir, desc: "Directory containing the pacts", default: Pact.configuration.pact_dir
|
21
|
+
method_option :doc_dir, desc: "Documentation directory", default: Pact.configuration.doc_dir
|
22
|
+
|
23
|
+
def docs
|
24
|
+
require 'pact/cli/generate_pact_docs'
|
25
|
+
require 'pact/doc/generator'
|
26
|
+
Pact::Doc::Generate.call(options[:pact_dir], options[:doc_dir], [Pact::Doc::Markdown::Generator])
|
27
|
+
end
|
28
|
+
|
18
29
|
end
|
19
30
|
end
|
data/lib/pact/consumer.rb
CHANGED
@@ -3,8 +3,5 @@ require 'pact/consumer/configuration'
|
|
3
3
|
require 'pact/consumer/consumer_contract_builder'
|
4
4
|
require 'pact/consumer/consumer_contract_builders'
|
5
5
|
require 'pact/consumer/interaction_builder'
|
6
|
-
require 'pact/consumer/mock_service'
|
7
|
-
require 'pact/consumer/mock_service_client'
|
8
|
-
require 'pact/consumer/app_manager'
|
9
6
|
require 'pact/term'
|
10
7
|
require 'pact/something_like'
|
@@ -38,13 +38,17 @@ module Pact
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def doc_generator= doc_generator
|
41
|
+
add_doc_generator doc_generator
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_doc_generator doc_generator
|
41
45
|
doc_generators << begin
|
42
46
|
if DOC_GENERATORS[doc_generator]
|
43
47
|
DOC_GENERATORS[doc_generator]
|
44
48
|
elsif doc_generator.respond_to?(:call)
|
45
49
|
doc_generator
|
46
50
|
else
|
47
|
-
raise "
|
51
|
+
raise "doc_generator needs to respond to call, or be in the preconfigured list: #{DOC_GENERATORS.keys}"
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'pact/
|
1
|
+
require 'pact/mock_service/app_manager'
|
2
2
|
require 'pact/consumer/consumer_contract_builder'
|
3
3
|
require 'pact/consumer/consumer_contract_builders'
|
4
4
|
require 'pact/consumer/world'
|
@@ -10,7 +10,7 @@ module Pact
|
|
10
10
|
|
11
11
|
extend Pact::DSL
|
12
12
|
|
13
|
-
attr_accessor :port, :standalone, :verify, :provider_name, :consumer_name
|
13
|
+
attr_accessor :port, :standalone, :verify, :provider_name, :consumer_name, :pact_specification_version
|
14
14
|
|
15
15
|
def initialize name, consumer_name, provider_name
|
16
16
|
@name = name
|
@@ -19,6 +19,7 @@ module Pact
|
|
19
19
|
@port = nil
|
20
20
|
@standalone = false
|
21
21
|
@verify = true
|
22
|
+
@pact_specification_version = nil
|
22
23
|
end
|
23
24
|
|
24
25
|
dsl do
|
@@ -33,6 +34,10 @@ module Pact
|
|
33
34
|
def verify verify
|
34
35
|
self.verify = verify
|
35
36
|
end
|
37
|
+
|
38
|
+
def pact_specification_version pact_specification_version
|
39
|
+
self.pact_specification_version = pact_specification_version
|
40
|
+
end
|
36
41
|
end
|
37
42
|
|
38
43
|
def finalize
|
@@ -45,7 +50,7 @@ module Pact
|
|
45
50
|
|
46
51
|
def register_mock_service
|
47
52
|
unless standalone
|
48
|
-
AppManager.instance.register_mock_service_for provider_name, "http://localhost:#{port}"
|
53
|
+
Pact::MockService::AppManager.instance.register_mock_service_for provider_name, "http://localhost:#{port}", mock_service_options
|
49
54
|
end
|
50
55
|
end
|
51
56
|
|
@@ -86,6 +91,10 @@ module Pact
|
|
86
91
|
def validate
|
87
92
|
raise "Please provide a port for service #{name}" unless port
|
88
93
|
end
|
94
|
+
|
95
|
+
def mock_service_options
|
96
|
+
{ pact_specification_version: pact_specification_version }
|
97
|
+
end
|
89
98
|
end
|
90
99
|
end
|
91
100
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'json/add/regexp'
|
3
3
|
require 'pact/logging'
|
4
|
-
require 'pact/
|
4
|
+
require 'pact/mock_service/client'
|
5
5
|
require 'pact/consumer/interaction_builder'
|
6
6
|
|
7
7
|
module Pact
|
@@ -21,7 +21,7 @@ module Pact
|
|
21
21
|
pactfile_write_mode: attributes[:pactfile_write_mode].to_s,
|
22
22
|
pact_dir: attributes.fetch(:pact_dir)
|
23
23
|
}
|
24
|
-
@mock_service_client =
|
24
|
+
@mock_service_client = Pact::MockService::Client.new(attributes[:port])
|
25
25
|
@mock_service_base_url = "http://localhost:#{attributes[:port]}"
|
26
26
|
end
|
27
27
|
|
@@ -1,20 +1,22 @@
|
|
1
1
|
require 'pact/doc/generate'
|
2
2
|
require 'pact/consumer/world'
|
3
|
+
require 'pact/mock_service/app_manager'
|
4
|
+
require 'pact/mock_service/client'
|
3
5
|
|
4
6
|
module Pact
|
5
7
|
module Consumer
|
6
8
|
class SpecHooks
|
7
9
|
|
8
10
|
def before_all
|
9
|
-
Pact::
|
11
|
+
Pact::MockService::AppManager.instance.spawn_all
|
10
12
|
FileUtils.mkdir_p Pact.configuration.pact_dir
|
11
13
|
end
|
12
14
|
|
13
15
|
def before_each example_description
|
14
16
|
Pact.consumer_world.register_pact_example_ran
|
15
17
|
Pact.configuration.logger.info "Clearing all expectations"
|
16
|
-
Pact::
|
17
|
-
Pact::
|
18
|
+
Pact::MockService::AppManager.instance.ports_of_mock_services.each do | port |
|
19
|
+
Pact::MockService::Client.clear_interactions port, example_description
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -29,8 +31,8 @@ module Pact
|
|
29
31
|
if Pact.consumer_world.any_pact_examples_ran?
|
30
32
|
Pact.consumer_world.consumer_contract_builders.each { | c | c.write_pact }
|
31
33
|
Pact::Doc::Generate.call
|
32
|
-
Pact::
|
33
|
-
Pact::
|
34
|
+
Pact::MockService::AppManager.instance.kill_all
|
35
|
+
Pact::MockService::AppManager.instance.clear_all
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# How to roll your own Doc Generator
|
2
|
+
|
3
|
+
1. Create a ConsumerContractRenderer that responds to `call` and accepts a `ConsumerContract` (this is the name for the domain model of a "pact"). This should return a String. For an example, see the [Markdown::ConsumerContractRenderer][consumer_contract_renderer].
|
4
|
+
2. Create an IndexRenderer. This allows you to create an index file for your docs. It should respond to `call` and accept the String name of the consumer, and a hash of Hash of `pact title => file_name`, and return a String. For an example, see the [Markdown::IndexRenderer][index_renderer].
|
5
|
+
3. Create a Generator. This is responsible for the overall file generating and writing process. Copy the [Markdown::Generator][generator] and configure it with your own ConsumerContractRenderer, IndexRenderer and file details.
|
6
|
+
|
7
|
+
If you would like to generate HTML documentation, see how the [HTMLPactRenderer][html_pact_renderer] in the Pact Broker does it.
|
8
|
+
|
9
|
+
[consumer_contract_renderer]: https://github.com/realestate-com-au/pact/blob/master/lib/pact/doc/markdown/consumer_contract_renderer.rb
|
10
|
+
[index_renderer]: https://github.com/realestate-com-au/pact/blob/master/lib/pact/doc/markdown/index_renderer.rb
|
11
|
+
[generator]: https://github.com/realestate-com-au/pact/blob/master/lib/pact/doc/markdown/generator.rb
|
12
|
+
[html_pact_renderer]: https://github.com/bethesque/pact_broker/blob/master/lib/pact_broker/api/renderers/html_pact_renderer.rb
|
13
|
+
|
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
@@ -28,8 +28,8 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.add_runtime_dependency 'webrick'
|
29
29
|
gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
|
30
30
|
|
31
|
-
gem.add_runtime_dependency 'pact-support', '~> 0.
|
32
|
-
gem.add_runtime_dependency 'pact-mock_service', '~> 0.
|
31
|
+
gem.add_runtime_dependency 'pact-support', '~> 0.3.0'
|
32
|
+
gem.add_runtime_dependency 'pact-mock_service', '~> 0.4.0'
|
33
33
|
|
34
34
|
gem.add_development_dependency 'rake', '~> 10.0.3'
|
35
35
|
gem.add_development_dependency 'webmock', '~> 1.18.0'
|
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.
|
4
|
+
version: 1.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-
|
16
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: randexp
|
@@ -166,7 +166,7 @@ dependencies:
|
|
166
166
|
requirements:
|
167
167
|
- - ~>
|
168
168
|
- !ruby/object:Gem::Version
|
169
|
-
version: 0.
|
169
|
+
version: 0.3.0
|
170
170
|
type: :runtime
|
171
171
|
prerelease: false
|
172
172
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -174,7 +174,7 @@ dependencies:
|
|
174
174
|
requirements:
|
175
175
|
- - ~>
|
176
176
|
- !ruby/object:Gem::Version
|
177
|
-
version: 0.
|
177
|
+
version: 0.3.0
|
178
178
|
- !ruby/object:Gem::Dependency
|
179
179
|
name: pact-mock_service
|
180
180
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,7 +182,7 @@ dependencies:
|
|
182
182
|
requirements:
|
183
183
|
- - ~>
|
184
184
|
- !ruby/object:Gem::Version
|
185
|
-
version: 0.
|
185
|
+
version: 0.4.0
|
186
186
|
type: :runtime
|
187
187
|
prerelease: false
|
188
188
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -190,7 +190,7 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - ~>
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: 0.
|
193
|
+
version: 0.4.0
|
194
194
|
- !ruby/object:Gem::Dependency
|
195
195
|
name: rake
|
196
196
|
requirement: !ruby/object:Gem::Requirement
|
@@ -338,6 +338,7 @@ files:
|
|
338
338
|
- bin/pact
|
339
339
|
- lib/pact.rb
|
340
340
|
- lib/pact/cli.rb
|
341
|
+
- lib/pact/cli/generate_pact_docs.rb
|
341
342
|
- lib/pact/cli/run_pact_verification.rb
|
342
343
|
- lib/pact/cli/spec_criteria.rb
|
343
344
|
- lib/pact/consumer.rb
|
@@ -353,6 +354,7 @@ files:
|
|
353
354
|
- lib/pact/consumer/rspec.rb
|
354
355
|
- lib/pact/consumer/spec_hooks.rb
|
355
356
|
- lib/pact/consumer/world.rb
|
357
|
+
- lib/pact/doc/README.md
|
356
358
|
- lib/pact/doc/doc_file.rb
|
357
359
|
- lib/pact/doc/generate.rb
|
358
360
|
- lib/pact/doc/generator.rb
|
@@ -420,7 +422,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
420
422
|
version: '0'
|
421
423
|
segments:
|
422
424
|
- 0
|
423
|
-
hash:
|
425
|
+
hash: 1564031949540050912
|
424
426
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
425
427
|
none: false
|
426
428
|
requirements:
|
@@ -429,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
429
431
|
version: '0'
|
430
432
|
segments:
|
431
433
|
- 0
|
432
|
-
hash:
|
434
|
+
hash: 1564031949540050912
|
433
435
|
requirements: []
|
434
436
|
rubyforge_project:
|
435
437
|
rubygems_version: 1.8.23
|