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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cdcb814012c42d3d775df3678b8d5c253424abd4513da41d200519c38a60525
4
- data.tar.gz: 829901b8e31e9278b310df2ec9b957425b00099eab97a7f4e6d2ba057f2c8e5a
3
+ metadata.gz: d09a52e010b09d1a4500bf4562c446accf5b87e2ea62275040895fc707a916d3
4
+ data.tar.gz: a1055e74617cc213375618e71c99a7fae61b5e4c87204732c3439fba4e8c7935
5
5
  SHA512:
6
- metadata.gz: 85a74f86ac93caa3edbff287b9feead78f58fd6f755ac8e5fd77a55d17086c00e8875c69f11d47e02a40e8a99be698d95f6764a6f64db5a16347e7a84b7b7027
7
- data.tar.gz: 745e3aeea217cc0b48bb8aa706369e6bc0fb1d4608e521e807b583b462bb0f7b39870950d069b6617c98e26f81879999132a6ad61718a58d9c77607fe222f669
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 langauge, and have a chat to one of us on the [pact-dev Google group][pact-dev].
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 the a mock service instance during at test suite is as follows:
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 pactfile_path do | file |
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
- file.truncate 0
62
- file.write new_contents
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 ||= Pact::ConsumerContractDecorator.new(consumer_contract, pact_specification_version: pact_specification_version)
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
- # This must only be read after the file has been locked
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
- Pact.configuration.error_stream.puts msg
126
+ error_stream.puts msg
115
127
  logger.warn msg
116
128
  end
117
129
 
118
130
  def info_and_puts msg
119
- $stdout.puts msg
131
+ output_stream.puts msg
120
132
  logger.info msg
121
133
  end
122
134
 
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "2.6.3"
3
+ VERSION = "2.6.4"
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: 2.6.3
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: 2017-12-18 00:00:00.000000000 Z
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.3
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