pact-mock_service 2.6.3 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +2 -2
- data/lib/pact/consumer_contract/consumer_contract_writer.rb +21 -9
- data/lib/pact/mock_service/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d09a52e010b09d1a4500bf4562c446accf5b87e2ea62275040895fc707a916d3
|
4
|
+
data.tar.gz: a1055e74617cc213375618e71c99a7fae61b5e4c87204732c3439fba4e8c7935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f866bc895e0bca3870808409c1b8fed2acc31372d3bba3db16d3bba371ccad209b7a628d66e2c588a15f90eebda2d7bf0f3b35b4e33a28603cdeaceda493952c
|
7
|
+
data.tar.gz: 51480cd67bdc8d87e12a119133537b4bb115ff828885e5f51723383e7081106f1d7da13f5b017417d069ac14636afe85131ff549f190ce0e25428c0ccf77e0be
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
<a name="v2.6.4"></a>
|
2
|
+
### v2.6.4 (2018-02-22)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* allow output streams and consumer contract writer to be passed in to Pact::ConsumerContractWriter ([1856f21](/../../commit/1856f21))
|
7
|
+
|
8
|
+
|
9
|
+
#### Bug Fixes
|
10
|
+
|
11
|
+
* correctly handle reading locked pact file on windows ([2d14562](/../../commit/2d14562))
|
12
|
+
|
13
|
+
|
1
14
|
<a name="v2.6.3"></a>
|
2
15
|
### v2.6.3 (2017-12-18)
|
3
16
|
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ The mock service provides the following endpoints:
|
|
16
16
|
|
17
17
|
All requests to the "administration" endpoints listed above must contain the header `X-Pact-Mock-Service: true` to allow the mock service to know whether the request is an administration request or a request from the actual consumer code.
|
18
18
|
|
19
|
-
As the Pact mock service can be used as a standalone executable and administered via HTTP, it can be used for testing with any language. All that is required is a library in the native language to create the HTTP calls listed above. Check out [docs.pact.io](https://docs.pact.io) for a list of implemented languages. If you are interested in creating bindings in a new
|
19
|
+
As the Pact mock service can be used as a standalone executable and administered via HTTP, it can be used for testing with any language. All that is required is a library in the native language to create the HTTP calls listed above. Check out [docs.pact.io](https://docs.pact.io) for a list of implemented languages. If you are interested in creating bindings in a new language, have a chat to one of us on the [pact-dev Google group][pact-dev].
|
20
20
|
|
21
21
|
## Installation
|
22
22
|
|
@@ -42,7 +42,7 @@ Run `pact-mock-service help` for command line options.
|
|
42
42
|
|
43
43
|
## Mock Service Usage
|
44
44
|
|
45
|
-
Each mock service process is designed to mock only ONE provider. To mock multiple providers, you will need to start a process for each provider. The lifecycle of
|
45
|
+
Each mock service process is designed to mock only ONE provider. To mock multiple providers, you will need to start a process for each provider. The lifecycle of a mock service instance during a test suite execution is as follows:
|
46
46
|
|
47
47
|
* _Before suite:_ start mock service
|
48
48
|
* _Before each test:_ clear interactions from previous test
|
@@ -25,6 +25,9 @@ module Pact
|
|
25
25
|
@pactfile_write_mode = (consumer_contract_details[:pactfile_write_mode] || :overwrite).to_sym
|
26
26
|
@interactions = consumer_contract_details.fetch(:interactions)
|
27
27
|
@pact_specification_version = (consumer_contract_details[:pact_specification_version] || DEFAULT_PACT_SPECIFICATION_VERSION).to_s
|
28
|
+
@consumer_contract_decorator_class = consumer_contract_details[:consumer_contract_decorator_class] || Pact::ConsumerContractDecorator
|
29
|
+
@error_stream = consumer_contract_details[:error_stream] || Pact.configuration.error_stream
|
30
|
+
@output_stream = consumer_contract_details[:output_stream] || Pact.configuration.output_stream
|
28
31
|
end
|
29
32
|
|
30
33
|
def consumer_contract
|
@@ -45,7 +48,8 @@ module Pact
|
|
45
48
|
|
46
49
|
private
|
47
50
|
|
48
|
-
attr_reader :consumer_contract_details, :pactfile_write_mode, :interactions, :logger, :pact_specification_version
|
51
|
+
attr_reader :consumer_contract_details, :pactfile_write_mode, :interactions, :logger, :pact_specification_version, :consumer_contract_decorator_class
|
52
|
+
attr_reader :error_stream, :output_stream
|
49
53
|
|
50
54
|
def update_pactfile_if_needed
|
51
55
|
return if pactfile_write_mode == :none
|
@@ -56,10 +60,15 @@ module Pact
|
|
56
60
|
def update_pactfile
|
57
61
|
logger.info log_message
|
58
62
|
FileUtils.mkdir_p File.dirname(pactfile_path)
|
59
|
-
Filelock
|
63
|
+
Filelock(pactfile_path) do | pact_file |
|
64
|
+
# must be read after obtaining the lock, and must be read from the yielded file object, otherwise windows freaks out
|
65
|
+
@existing_contents = pact_file.read
|
60
66
|
new_contents = pact_json
|
61
|
-
|
62
|
-
|
67
|
+
pact_file.rewind
|
68
|
+
pact_file.truncate 0
|
69
|
+
pact_file.write new_contents
|
70
|
+
pact_file.flush
|
71
|
+
pact_file.truncate(pact_file.pos)
|
63
72
|
end
|
64
73
|
end
|
65
74
|
|
@@ -68,7 +77,7 @@ module Pact
|
|
68
77
|
end
|
69
78
|
|
70
79
|
def decorated_pact
|
71
|
-
@decorated_pact ||=
|
80
|
+
@decorated_pact ||= consumer_contract_decorator_class.new(consumer_contract, pact_specification_version: pact_specification_version)
|
72
81
|
end
|
73
82
|
|
74
83
|
def interactions_for_new_consumer_contract
|
@@ -105,18 +114,21 @@ module Pact
|
|
105
114
|
File.size(pactfile_path) != 0
|
106
115
|
end
|
107
116
|
|
117
|
+
def existing_contents
|
118
|
+
@existing_contents
|
119
|
+
end
|
120
|
+
|
108
121
|
def existing_consumer_contract
|
109
|
-
|
110
|
-
Pact::ConsumerContract.from_uri(pactfile_path)
|
122
|
+
@existing_consumer_contract ||= Pact::ConsumerContract.from_json(existing_contents)
|
111
123
|
end
|
112
124
|
|
113
125
|
def warn_and_stderr msg
|
114
|
-
|
126
|
+
error_stream.puts msg
|
115
127
|
logger.warn msg
|
116
128
|
end
|
117
129
|
|
118
130
|
def info_and_puts msg
|
119
|
-
|
131
|
+
output_stream.puts msg
|
120
132
|
logger.info msg
|
121
133
|
end
|
122
134
|
|
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: 2.6.
|
4
|
+
version: 2.6.4
|
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:
|
15
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rack
|
@@ -398,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
398
398
|
version: '0'
|
399
399
|
requirements: []
|
400
400
|
rubyforge_project:
|
401
|
-
rubygems_version: 2.7.
|
401
|
+
rubygems_version: 2.7.6
|
402
402
|
signing_key:
|
403
403
|
specification_version: 4
|
404
404
|
summary: Provides a mock service for use with Pact
|