pact 1.14.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fb2ea12b63cd90b9451173dd6deb6a10146d426
4
- data.tar.gz: 2ba870980eb5403ab32c405138315b6f471b189e
3
+ metadata.gz: 4f12dd3c9ccdf082d1816783d7defa13ee9df47b
4
+ data.tar.gz: 0221ad15770f29536daea315b64f965579e9a4fb
5
5
  SHA512:
6
- metadata.gz: 517699fa66be479723e0f703dc00e5453482d18d5463b59176b8fd09138211c648dfa8f654223690f77c1cbe4cafad7ae98165c97b3561e69248a7bb4ad204f4
7
- data.tar.gz: 44ef94d0fa65a5ee0b003ec3e7f8c6915da6c8ecadce6c690fa9c5a50e507f313f39b802839e3671cbfb5aea54ea9c4735d86a5ee1f854f37533333d37851985
6
+ metadata.gz: 68ca83ab0bfab86a947a582adee3b3583ef1fe429d372660f738e9c977be6987e80de122f5d8e93ef1b1159d40d186df8c26b9d67c7839f76d7d46e3d8633a8e
7
+ data.tar.gz: cc1ca09bcac2acee98480ef4b92237328686eb8a6e73f8d868f168ea29842155979871f244287c5a0d56785c936dacb2051418b95736d592a5e7ca5beaf6a28a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@ Do this to generate your change history
2
2
 
3
3
  git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ ## 1.16.0 (25 September 2017)
6
+ * 70e67cf - feat: improve description of rspec header matching 'it' blocks and failure text (Beth Skurrie, Mon Sep 25 08:46:06 2017 +1000)
7
+ * 85d8e09 - fix: correctly display pact term when parent key is missing (Beth Skurrie, Mon Sep 25 08:43:02 2017 +1000)
8
+
9
+ ## 1.15.0 (11 August 2017)
10
+ * a950a16 - fix: Fix module declaration (Beth Skurrie, Fri Aug 11 11:47:46 2017 +1000)
11
+ * 14cd969 - feat(output): Remove ruby specific text from pact verification output. (Beth Skurrie, Tue Aug 8 17:12:50 2017 +1000)
12
+
5
13
  ## 1.14.0 (19 June 2017)
6
14
  * eb44499 - Updated pact-support version (Beth Skurrie, Mon Jun 19 09:51:13 2017 +1000)
7
15
  * 8835496 - Changed colour of acutal response body output (Beth Skurrie, Tue Jun 6 10:44:45 2017 +1000)
@@ -19,6 +19,20 @@ module Pact
19
19
  "Expected header \"#{header_name}\" to #{expected_desc(expected)}, but was #{actual_desc(actual)}"
20
20
  end
21
21
 
22
+ def expected_desc_for_it expected
23
+ case expected
24
+ when NilClass then "is nil"
25
+ when Regexp
26
+ "matches #{expected.inspect}"
27
+ when Pact::Term
28
+ "matches #{expected.matcher.inspect}"
29
+ when Pact::SomethingLike
30
+ "is an instance of #{Pact::Reification.from_term(expected).class}"
31
+ else
32
+ "equals #{expected.inspect}"
33
+ end
34
+ end
35
+
22
36
  private
23
37
 
24
38
  def colorize_if_enabled formatted_diff, color_enabled
@@ -35,15 +49,20 @@ module Pact
35
49
  def expected_desc expected
36
50
  case expected
37
51
  when NilClass then "be nil"
38
- else
52
+ when Regexp
39
53
  "match #{expected.inspect}"
54
+ when Pact::Term
55
+ "match #{expected.matcher.inspect}"
56
+ when Pact::SomethingLike
57
+ "be an instance of #{Pact::Reification.from_term(expected).class}"
58
+ else
59
+ "equal #{expected.inspect}"
40
60
  end
41
61
  end
42
62
 
43
63
  def actual_desc actual
44
64
  actual.nil? ? 'nil' : '"' + actual + '"'
45
65
  end
46
-
47
66
  end
48
67
  end
49
68
  end
@@ -29,7 +29,9 @@ module Pact
29
29
  end
30
30
 
31
31
  def print_missing_provider_states
32
- PrintMissingProviderStates.call Pact.provider_world.provider_states.missing_provider_states, output
32
+ if executing_with_ruby?
33
+ PrintMissingProviderStates.call Pact.provider_world.provider_states.missing_provider_states, output
34
+ end
33
35
  end
34
36
 
35
37
  def interaction_rerun_commands
@@ -39,26 +41,33 @@ module Pact
39
41
  end
40
42
 
41
43
  def interaction_rerun_command_for example
42
- provider_state = example.metadata[:pact_interaction].provider_state
43
- description = example.metadata[:pact_interaction].description
44
- pactfile_uri = example.metadata[:pactfile_uri]
45
44
  example_description = example.metadata[:pact_interaction_example_description]
46
- failure_color("bundle exec rake pact:verify:at[#{pactfile_uri}] PACT_DESCRIPTION=\"#{description}\" PACT_PROVIDER_STATE=\"#{provider_state}\"") + " " + detail_color("# #{example_description}")
45
+ if ENV['PACT_INTERACTION_RERUN_COMMAND']
46
+ cmd = String.new(ENV['PACT_INTERACTION_RERUN_COMMAND'])
47
+ provider_state = example.metadata[:pact_interaction].provider_state
48
+ description = example.metadata[:pact_interaction].description
49
+ pactfile_uri = example.metadata[:pactfile_uri]
50
+ cmd.gsub!("<PACT_URI>", pactfile_uri.to_s)
51
+ cmd.gsub!("<PACT_DESCRIPTION>", description)
52
+ cmd.gsub!("<PACT_PROVIDER_STATE>", "#{provider_state}")
53
+ failure_color(cmd) + " " + detail_color("# #{example_description}")
54
+ else
55
+ failure_color("* #{example_description}")
56
+ end
47
57
  end
48
58
 
49
59
  def print_failure_message
50
- output.puts failure_message
60
+ output.puts(failure_message) if executing_with_ruby?
51
61
  end
52
62
 
53
63
  def failure_message
54
64
  "\n" + Pact::Provider::Help::PromptText.() + "\n"
55
65
  end
56
66
 
67
+ def executing_with_ruby?
68
+ ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby'
69
+ end
57
70
  end
58
-
59
71
  end
60
-
61
72
  end
62
73
  end
63
-
64
-
@@ -55,26 +55,35 @@ module Pact
55
55
  end
56
56
 
57
57
  def print_missing_provider_states
58
- PrintMissingProviderStates.call Pact.provider_world.provider_states.missing_provider_states, output
58
+ if executing_with_ruby?
59
+ PrintMissingProviderStates.call Pact.provider_world.provider_states.missing_provider_states, output
60
+ end
59
61
  end
60
62
 
61
63
  def interaction_rerun_commands summary
62
64
  summary.failed_examples.collect do |example|
63
65
  interaction_rerun_command_for example
64
- end.uniq
66
+ end.uniq.compact
65
67
  end
66
68
 
67
69
  def interaction_rerun_command_for example
68
- provider_state = example.metadata[:pact_interaction].provider_state
69
- description = example.metadata[:pact_interaction].description
70
- pactfile_uri = example.metadata[:pactfile_uri]
71
70
  example_description = example.metadata[:pact_interaction_example_description]
72
- colorizer.wrap("bundle exec rake pact:verify:at[#{pactfile_uri}] PACT_DESCRIPTION=\"#{description}\" PACT_PROVIDER_STATE=\"#{provider_state}\" ", ::RSpec.configuration.failure_color) +
73
- colorizer.wrap("# #{example_description}", ::RSpec.configuration.detail_color)
71
+ if ENV['PACT_INTERACTION_RERUN_COMMAND']
72
+ cmd = String.new(ENV['PACT_INTERACTION_RERUN_COMMAND'])
73
+ provider_state = example.metadata[:pact_interaction].provider_state
74
+ description = example.metadata[:pact_interaction].description
75
+ pactfile_uri = example.metadata[:pactfile_uri]
76
+ cmd.gsub!("<PACT_URI>", pactfile_uri.to_s)
77
+ cmd.gsub!("<PACT_DESCRIPTION>", description)
78
+ cmd.gsub!("<PACT_PROVIDER_STATE>", "#{provider_state}")
79
+ colorizer.wrap("#{cmd} ", ::RSpec.configuration.failure_color) + colorizer.wrap("# #{example_description}", ::RSpec.configuration.detail_color)
80
+ else
81
+ colorizer.wrap("* #{example_description}", ::RSpec.configuration.failure_color)
82
+ end
74
83
  end
75
84
 
76
85
  def print_failure_message
77
- output.puts failure_message
86
+ output.puts(failure_message) if executing_with_ruby?
78
87
  end
79
88
 
80
89
  def failure_message
@@ -85,11 +94,11 @@ module Pact
85
94
  @colorizer ||= ::RSpec::Core::Formatters::ConsoleCodes
86
95
  end
87
96
 
97
+ def executing_with_ruby?
98
+ ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby'
99
+ end
88
100
  end
89
-
90
101
  end
91
-
92
102
  end
93
103
  end
94
104
 
95
-
@@ -3,6 +3,8 @@ require 'pact/consumer_contract'
3
3
  require 'pact/provider/rspec/matchers'
4
4
  require 'pact/provider/test_methods'
5
5
  require 'pact/provider/configuration'
6
+ require 'pact/provider/matchers/messages'
7
+
6
8
 
7
9
  module Pact
8
10
  module Provider
@@ -90,7 +92,7 @@ module Pact
90
92
  end
91
93
  end
92
94
 
93
- describe_response Pact::Response.new(Pact::Term.unpack_regexps(interaction.response)), interaction_context
95
+ describe_response Pact::Response.new(interaction.response), interaction_context
94
96
 
95
97
  end
96
98
 
@@ -103,6 +105,7 @@ module Pact
103
105
  describe "returns a response which" do
104
106
 
105
107
  include Pact::RSpec::Matchers
108
+ extend Pact::Matchers::Messages
106
109
 
107
110
  let(:expected_response_status) { expected_response.status }
108
111
  let(:expected_response_body) { expected_response.body }
@@ -125,7 +128,7 @@ module Pact
125
128
  if expected_response.headers
126
129
  describe "includes headers" do
127
130
  expected_response.headers.each do |name, expected_header_value|
128
- it "\"#{name}\" with value #{expected_header_value.inspect}" do
131
+ it "\"#{name}\" which #{expected_desc_for_it(expected_header_value)}" do
129
132
  header_value = response.headers[name]
130
133
  expect(header_value).to match_header(name, expected_header_value)
131
134
  end
@@ -1,13 +1,15 @@
1
1
  require 'rspec/mocks'
2
2
 
3
3
  module Pact
4
- module Provider::State
5
- module ProviderStateConfiguredModules
4
+ module Provider
5
+ module State
6
+ module ProviderStateConfiguredModules
6
7
 
7
- include ::RSpec::Mocks::ExampleMethods
8
+ include ::RSpec::Mocks::ExampleMethods
8
9
 
9
- # Placeholder for modules configured using config.include
10
+ # Placeholder for modules configured using config.include
10
11
 
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -5,6 +5,8 @@ require 'shellwords'
5
5
  module Pact
6
6
  module TaskHelper
7
7
 
8
+ PACT_INTERACTION_RERUN_COMMAND = "bundle exec rake pact:verify:at[<PACT_URI>] PACT_DESCRIPTION=\"<PACT_DESCRIPTION>\" PACT_PROVIDER_STATE=\"<PACT_PROVIDER_STATE>\""
9
+
8
10
  extend self
9
11
 
10
12
  def execute_pact_verify pact_uri = nil, pact_helper = nil, rspec_opts = nil
@@ -35,8 +37,19 @@ module Pact
35
37
 
36
38
  def execute_cmd command
37
39
  $stdout.puts command
38
- system(command) ? 0 : 1
40
+ temporarily_set_env_var 'PACT_EXECUTING_LANGUAGE', 'ruby' do
41
+ temporarily_set_env_var 'PACT_INTERACTION_RERUN_COMMAND', PACT_INTERACTION_RERUN_COMMAND do
42
+ exit_status = system(command) ? 0 : 1
43
+ end
44
+ end
39
45
  end
40
46
 
47
+ def temporarily_set_env_var name, value
48
+ original_value = ENV[name]
49
+ ENV[name] ||= value
50
+ yield
51
+ ensure
52
+ ENV[name] = original_value
53
+ end
41
54
  end
42
55
  end
@@ -19,4 +19,4 @@
19
19
 
20
20
  * Check out https://github.com/realestate-com-au/pact/wiki/Troubleshooting
21
21
 
22
- * Ask a question in the google users' group https://groups.google.com/forum/#!forum/pact-support
22
+ * Ask a question on stackoverflow and tag it `pact-ruby`
data/lib/pact/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # Remember to bump pact-provider-proxy when this changes major version
1
2
  module Pact
2
- VERSION = "1.14.0"
3
+ VERSION = "1.16.0"
3
4
  end
data/pact.gemspec CHANGED
@@ -28,7 +28,7 @@ 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', '~> 1.1'
31
+ gem.add_runtime_dependency 'pact-support', '~> 1.1', '>=1.1.8'
32
32
  gem.add_runtime_dependency 'pact-mock_service', '~> 2.0'
33
33
 
34
34
  gem.add_development_dependency 'rake', '~> 10.0.3'
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.14.0
4
+ version: 1.16.0
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-06-18 00:00:00.000000000 Z
15
+ date: 2017-09-25 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp
@@ -119,6 +119,9 @@ dependencies:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
121
  version: '1.1'
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 1.1.8
122
125
  type: :runtime
123
126
  prerelease: false
124
127
  version_requirements: !ruby/object:Gem::Requirement
@@ -126,6 +129,9 @@ dependencies:
126
129
  - - "~>"
127
130
  - !ruby/object:Gem::Version
128
131
  version: '1.1'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.1.8
129
135
  - !ruby/object:Gem::Dependency
130
136
  name: pact-mock_service
131
137
  requirement: !ruby/object:Gem::Requirement
@@ -367,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
373
  version: '0'
368
374
  requirements: []
369
375
  rubyforge_project:
370
- rubygems_version: 2.4.5
376
+ rubygems_version: 2.6.11
371
377
  signing_key:
372
378
  specification_version: 4
373
379
  summary: Enables consumer driven contract testing, providing a mock service and DSL