pact 1.1.0 → 1.1.1

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.
Files changed (66) hide show
  1. data/CHANGELOG.md +31 -20
  2. data/Gemfile.lock +12 -12
  3. data/README.md +32 -16
  4. data/Rakefile +3 -3
  5. data/documentation/README.md +1 -0
  6. data/documentation/development-workflow.md +22 -0
  7. data/documentation/faq.md +8 -0
  8. data/documentation/provider-states.md +2 -0
  9. data/documentation/troubleshooting.md +4 -0
  10. data/documentation/verifying-pacts.md +97 -0
  11. data/lib/pact/app.rb +98 -4
  12. data/lib/pact/consumer/rspec.rb +3 -2
  13. data/lib/pact/doc/doc_file.rb +4 -4
  14. data/lib/pact/doc/generator.rb +3 -3
  15. data/lib/pact/doc/interaction_view_model.rb +1 -0
  16. data/lib/pact/doc/markdown/{interactions_renderer.rb → consumer_contract_renderer.rb} +1 -1
  17. data/lib/pact/doc/markdown/generator.rb +2 -2
  18. data/lib/pact/matchers/unix_diff_formatter.rb +1 -1
  19. data/lib/pact/project_root.rb +7 -0
  20. data/lib/pact/provider.rb +0 -1
  21. data/lib/pact/provider/context.rb +0 -0
  22. data/lib/pact/provider/matchers/messages.rb +15 -13
  23. data/lib/pact/provider/pact_spec_runner.rb +21 -22
  24. data/lib/pact/provider/rspec.rb +22 -15
  25. data/lib/pact/provider/rspec/custom_options_file +0 -0
  26. data/lib/pact/provider/{matchers.rb → rspec/matchers.rb} +2 -1
  27. data/lib/pact/rspec.rb +20 -0
  28. data/lib/pact/shared/request.rb +1 -1
  29. data/lib/pact/tasks/task_helper.rb +18 -15
  30. data/lib/pact/tasks/verification_task.rb +26 -32
  31. data/lib/pact/version.rb +1 -1
  32. data/lib/tasks/pact.rake +5 -11
  33. data/spec/integration/pact/consumer_configuration_spec.rb +3 -3
  34. data/spec/lib/pact/app_spec.rb +47 -0
  35. data/spec/lib/pact/consumer/app_manager_spec.rb +1 -1
  36. data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +3 -3
  37. data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +10 -2
  38. data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +2 -2
  39. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +1 -1
  40. data/spec/lib/pact/consumer_contract/interaction_spec.rb +4 -4
  41. data/spec/lib/pact/consumer_contract/request_spec.rb +23 -23
  42. data/spec/lib/pact/doc/generator_spec.rb +4 -4
  43. data/spec/lib/pact/doc/markdown/{interactions_renderer_spec.rb → consumer_contract_renderer_spec.rb} +4 -4
  44. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +8 -8
  45. data/spec/lib/pact/provider/configuration/configuration_extension_spec.rb +2 -2
  46. data/spec/lib/pact/provider/matchers/messages_spec.rb +17 -6
  47. data/spec/lib/pact/provider/rspec/formatter_spec.rb +3 -1
  48. data/spec/lib/pact/shared/dsl_spec.rb +1 -1
  49. data/spec/lib/pact/shared/request_spec.rb +8 -0
  50. data/spec/lib/pact/tasks/task_helper_spec.rb +39 -54
  51. data/spec/lib/pact/tasks/verification_task_spec.rb +75 -0
  52. data/spec/pact_specification/compliance-1.0.0.rb +47 -0
  53. data/spec/spec_helper.rb +2 -6
  54. data/spec/standalone/consumer_fail_test.rb +1 -0
  55. data/spec/standalone/consumer_pass_test.rb +1 -0
  56. data/spec/support/active_support_if_configured.rb +6 -0
  57. data/spec/support/pact_helper.rb +2 -1
  58. data/spec/support/shared_examples_for_request.rb +15 -4
  59. data/spec/support/spec_support.rb +3 -0
  60. data/spec/support/stubbing_using_allow.rb +1 -0
  61. data/spec/support/term.json +13 -1
  62. data/tasks/pact-test.rake +45 -26
  63. metadata +23 -13
  64. data/lib/pact/provider/client_project_pact_helper.rb +0 -4
  65. data/spec/lib/pact/provider/pact_spec_runner_spec.rb +0 -7
  66. data/spec/lib/pact/verification_task_spec.rb +0 -99
@@ -1,5 +1,6 @@
1
1
  require 'pact/consumer'
2
2
  require 'pact/consumer/spec_hooks'
3
+ require 'pact/rspec'
3
4
 
4
5
  module Pact
5
6
  module Consumer
@@ -19,11 +20,11 @@ RSpec.configure do |config|
19
20
  end
20
21
 
21
22
  config.before :each, :pact => true do | example |
22
- hooks.before_each example.example.full_description
23
+ hooks.before_each Pact::RSpec.full_description(example)
23
24
  end
24
25
 
25
26
  config.after :each, :pact => true do | example |
26
- hooks.after_each example.example.full_description
27
+ hooks.after_each Pact::RSpec.full_description(example)
27
28
  end
28
29
 
29
30
  config.after :suite do
@@ -3,10 +3,10 @@ module Pact
3
3
 
4
4
  class DocFile
5
5
 
6
- def initialize consumer_contract, dir, interactions_renderer, file_extension
6
+ def initialize consumer_contract, dir, consumer_contract_renderer, file_extension
7
7
  @dir = dir
8
8
  @consumer_contract = consumer_contract
9
- @interactions_renderer = interactions_renderer
9
+ @consumer_contract_renderer = consumer_contract_renderer
10
10
  @file_extension = file_extension
11
11
  end
12
12
 
@@ -24,7 +24,7 @@ module Pact
24
24
 
25
25
  private
26
26
 
27
- attr_reader :dir, :consumer_contract, :interactions_renderer, :file_extension
27
+ attr_reader :dir, :consumer_contract, :consumer_contract_renderer, :file_extension
28
28
 
29
29
 
30
30
  def path
@@ -32,7 +32,7 @@ module Pact
32
32
  end
33
33
 
34
34
  def doc_file_contents
35
- interactions_renderer.call(consumer_contract)
35
+ consumer_contract_renderer.call(consumer_contract)
36
36
  end
37
37
 
38
38
  end
@@ -9,7 +9,7 @@ module Pact
9
9
  def initialize pact_dir, doc_dir, options
10
10
  @doc_dir = doc_dir
11
11
  @pact_dir = pact_dir
12
- @interactions_renderer = options[:interactions_renderer]
12
+ @consumer_contract_renderer = options[:consumer_contract_renderer]
13
13
  @doc_type = options[:doc_type]
14
14
  @file_extension = options[:file_extension]
15
15
  @index_renderer = options[:index_renderer]
@@ -26,7 +26,7 @@ module Pact
26
26
 
27
27
  private
28
28
 
29
- attr_reader :doc_dir, :pact_dir, :interactions_renderer, :doc_type, :file_extension, :index_renderer, :after
29
+ attr_reader :doc_dir, :pact_dir, :consumer_contract_renderer, :doc_type, :file_extension, :index_renderer, :after
30
30
 
31
31
  def write_index
32
32
  File.open(index_file_path, "w") { |io| io << index_file_contents }
@@ -52,7 +52,7 @@ module Pact
52
52
 
53
53
  def doc_files
54
54
  consumer_contracts.collect do | consumer_contract |
55
- DocFile.new(consumer_contract, target_dir, interactions_renderer, file_extension)
55
+ DocFile.new(consumer_contract, target_dir, consumer_contract_renderer, file_extension)
56
56
  end
57
57
  end
58
58
 
@@ -1,4 +1,5 @@
1
1
  require 'pact/shared/active_support_support'
2
+ require 'pact/reification'
2
3
 
3
4
  module Pact
4
5
  module Doc
@@ -4,7 +4,7 @@ require 'pact/doc/sort_interactions'
4
4
  module Pact
5
5
  module Doc
6
6
  module Markdown
7
- class InteractionsRenderer
7
+ class ConsumerContractRenderer
8
8
 
9
9
  def initialize consumer_contract
10
10
  @consumer_contract = consumer_contract
@@ -1,5 +1,5 @@
1
1
  require 'pact/doc/generator'
2
- require 'pact/doc/markdown/interactions_renderer'
2
+ require 'pact/doc/markdown/consumer_contract_renderer'
3
3
  require 'pact/doc/markdown/index_renderer'
4
4
 
5
5
  module Pact
@@ -9,7 +9,7 @@ module Pact
9
9
 
10
10
  def initialize pact_dir, doc_dir
11
11
  super(pact_dir, doc_dir,
12
- interactions_renderer: InteractionsRenderer,
12
+ consumer_contract_renderer: ConsumerContractRenderer,
13
13
  doc_type: 'markdown',
14
14
  file_extension: '.md',
15
15
  index_renderer: IndexRenderer,
@@ -24,7 +24,7 @@ module Pact
24
24
  def to_s
25
25
  expected = generate_string(diff, :expected)
26
26
  actual = generate_string(diff, :actual)
27
- Pact::Matchers::Differ.new(@colour).diff_as_string actual, expected
27
+ Pact::Matchers::Differ.new(@colour).diff_as_string(actual, expected).lstrip
28
28
  end
29
29
 
30
30
  private
@@ -0,0 +1,7 @@
1
+ require 'pathname'
2
+
3
+ module Pact
4
+ def self.project_root
5
+ @project_root ||= Pathname.new(File.expand_path('../../../',__FILE__)).freeze
6
+ end
7
+ end
@@ -1,4 +1,3 @@
1
1
  require 'pact/configuration'
2
2
  require 'pact/provider/configuration'
3
- require 'pact/provider/pact_spec_runner'
4
3
  require 'pact/provider/world'
File without changes
@@ -5,32 +5,34 @@ module Pact
5
5
  module Matchers
6
6
  module Messages
7
7
 
8
- def match_term_failure_message diff, color_enabled
9
- message = Pact.configuration.diff_formatter.call(diff)
8
+ def match_term_failure_message diff, actual, color_enabled
9
+ message = "Actual: #{(String === actual ? actual : actual.to_json)}\n\n"
10
+ formatted_diff = Pact.configuration.diff_formatter.call(diff)
11
+ message + colorize_if_enabled(formatted_diff, color_enabled)
12
+ end
13
+
14
+ def match_header_failure_message header_name, expected, actual
15
+ "Expected header \"#{header_name}\" to #{expected_desc(expected)}, but was #{actual_desc(actual)}"
16
+ end
17
+
18
+ private
10
19
 
20
+ def colorize_if_enabled formatted_diff, color_enabled
11
21
  if color_enabled
12
22
  # RSpec wraps each line in the failure message with failure_color, turning it red.
13
23
  # To ensure the lines in the diff that should be white, stay white, put an
14
24
  # ANSI reset at the start of each line.
15
- message.split("\n").collect{ |line| ::Term::ANSIColor.reset + line }.join("\n")
25
+ formatted_diff.split("\n").collect{ |line| ::Term::ANSIColor.reset + line }.join("\n")
16
26
  else
17
- message
27
+ formatted_diff
18
28
  end
19
-
20
29
  end
21
30
 
22
- def match_header_failure_message header_name, expected, actual
23
- "Expected header \"#{header_name}\" to #{expected_desc(expected)}, but was #{actual_desc(actual)}"
24
- end
25
-
26
- private
27
-
28
31
  def expected_desc expected
29
32
  case expected
30
- when Pact::Term then "match #{expected.matcher.inspect}"
31
33
  when NilClass then "be nil"
32
34
  else
33
- "match \"#{expected}\""
35
+ "match #{expected.inspect}"
34
36
  end
35
37
  end
36
38
 
@@ -6,6 +6,9 @@ require 'rspec/core/formatters/json_formatter'
6
6
  require 'pact/provider/pact_helper_locator'
7
7
  require 'pact/provider/rspec/formatter'
8
8
  require 'pact/provider/rspec/silent_json_formatter'
9
+ require 'pact/project_root'
10
+ require 'pact/rspec'
11
+
9
12
  require_relative 'rspec'
10
13
 
11
14
 
@@ -15,11 +18,6 @@ module Pact
15
18
 
16
19
  include Pact::Provider::RSpec::ClassMethods
17
20
 
18
- SUPPORT_FILE_DEPRECATION_MESSAGE = "The :support_file option is deprecated. " +
19
- "The preferred way to specify a support file is to create a pact_helper.rb in one of the following paths: " +
20
- Pact::Provider::PactHelperLocater::PACT_HELPER_FILE_PATTERNS.join(", ") +
21
- ". If you cannot do this, you may use the :pact_helper option in place of the :support_file option."
22
-
23
21
  attr_reader :spec_definitions
24
22
  attr_reader :options
25
23
  attr_reader :output
@@ -43,22 +41,8 @@ module Pact
43
41
 
44
42
  private
45
43
 
46
- def require_pact_helper spec_definition
47
- if spec_definition[:pact_helper]
48
- Pact.configuration.output_stream.puts "Using #{spec_definition[:pact_helper]}"
49
- require spec_definition[:pact_helper]
50
- elsif spec_definition[:support_file]
51
- Pact.configuration.output_stream.puts "Using #{spec_definition[:support_file]}"
52
- Pact.configuration.error_stream.puts SUPPORT_FILE_DEPRECATION_MESSAGE
53
- require spec_definition[:support_file]
54
- else
55
- require 'pact/provider/client_project_pact_helper'
56
- end
57
- end
58
-
59
44
  def initialize_specs
60
45
  spec_definitions.each do | spec_definition |
61
- require_pact_helper spec_definition
62
46
  options = {
63
47
  consumer: spec_definition[:consumer],
64
48
  save_pactfile_to_tmp: true,
@@ -73,7 +57,7 @@ module Pact
73
57
 
74
58
  config.color = true
75
59
  config.pattern = "pattern which doesn't match any files"
76
- config.backtrace_inclusion_patterns = [/pact\/provider\/rspec/]
60
+ config.backtrace_inclusion_patterns = [Regexp.new(Dir.getwd), /pact.*pact\.rake.*2/]
77
61
  config.backtrace_exclusion_patterns << /pact/
78
62
 
79
63
  config.extend Pact::Provider::RSpec::ClassMethods
@@ -102,12 +86,27 @@ module Pact
102
86
  end
103
87
 
104
88
  def run_specs
105
- exit_code = ::RSpec::Core::CommandLine.new(NoConfigurationOptions.new)
106
- .run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
89
+ exit_code = if Pact::RSpec.runner_defined?
90
+ ::RSpec::Core::Runner.run(rspec_runner_options,
91
+ ::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
92
+ else
93
+ ::RSpec::Core::CommandLine.new(NoConfigurationOptions.new)
94
+ .run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
95
+ end
107
96
  @output = JSON.parse(Pact.world.json_formatter_stream.string, symbolize_keys: true)
108
97
  exit_code
109
98
  end
110
99
 
100
+ def rspec_runner_options
101
+ ["--options", Pact.project_root.join("lib/pact/provider/rspec/custom_options_file").to_s]
102
+ end
103
+
104
+ def class_exists? name
105
+ Kernel.const_get name
106
+ rescue NameError
107
+ false
108
+ end
109
+
111
110
  class NoConfigurationOptions
112
111
  def method_missing(method, *args, &block)
113
112
  # Do nothing!
@@ -1,6 +1,6 @@
1
1
  require 'open-uri'
2
2
  require 'pact/consumer_contract'
3
- require 'pact/provider/matchers'
3
+ require 'pact/provider/rspec/matchers'
4
4
  require 'pact/provider/test_methods'
5
5
  require 'pact/provider/configuration'
6
6
 
@@ -19,7 +19,9 @@ module Pact
19
19
  include ::RSpec::Core::DSL
20
20
 
21
21
  def honour_pactfile pactfile_uri, options = {}
22
- puts "Filtering specs by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any?
22
+ #TODO change puts to use output stream
23
+ puts "Reading pact at #{pactfile_uri}"
24
+ puts "Filtering interactions by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any?
23
25
  consumer_contract = Pact::ConsumerContract.from_json(read_pact_from(pactfile_uri, options))
24
26
  describe "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}", :pactfile_uri => pactfile_uri do
25
27
  honour_consumer_contract consumer_contract, options
@@ -66,24 +68,29 @@ module Pact
66
68
 
67
69
  describe description_for(interaction), metadata do
68
70
 
69
- interaction_context = InteractionContext.new
71
+ describe "with #{interaction.request.method_and_path}" do
70
72
 
71
- before do
72
- interaction_context.run_once :before do
73
- Pact.configuration.logger.info "Running example '#{self.example.full_description}'"
74
- set_up_provider_state interaction.provider_state, options[:consumer]
75
- replay_interaction interaction
76
- interaction_context.last_response = last_response
73
+ interaction_context = InteractionContext.new
74
+
75
+ before do | example |
76
+ interaction_context.run_once :before do
77
+ Pact.configuration.logger.info "Running example '#{Pact::RSpec.full_description(example)}'"
78
+ set_up_provider_state interaction.provider_state, options[:consumer]
79
+ replay_interaction interaction
80
+ interaction_context.last_response = last_response
81
+ end
77
82
  end
78
- end
79
83
 
80
- after do
81
- interaction_context.run_once :after do
82
- tear_down_provider_state interaction.provider_state, options[:consumer]
84
+ after do
85
+ interaction_context.run_once :after do
86
+ tear_down_provider_state interaction.provider_state, options[:consumer]
87
+ end
83
88
  end
89
+
90
+ describe_response Pact::Term.unpack_regexps(interaction.response), interaction_context
91
+
84
92
  end
85
93
 
86
- describe_response interaction.response, interaction_context
87
94
  end
88
95
 
89
96
  end
@@ -107,7 +114,7 @@ module Pact
107
114
  if expected_response['headers']
108
115
  describe "includes headers" do
109
116
  expected_response['headers'].each do |name, expected_header_value|
110
- it "\"#{name}\" with value \"#{expected_header_value}\"" do
117
+ it "\"#{name}\" with value #{expected_header_value.inspect}" do
111
118
  header_value = response.headers[name]
112
119
  expect(header_value).to match_header(name, expected_header_value)
113
120
  end
@@ -1,6 +1,7 @@
1
1
  require 'rspec'
2
2
  require 'pact/matchers'
3
3
  require 'pact/provider/matchers/messages'
4
+ require 'pact/rspec'
4
5
 
5
6
  RSpec::Matchers.define :match_term do |expected|
6
7
 
@@ -12,7 +13,7 @@ RSpec::Matchers.define :match_term do |expected|
12
13
  end
13
14
 
14
15
  failure_message_for_should do | actual |
15
- match_term_failure_message @difference, ::RSpec.configuration.color_enabled
16
+ match_term_failure_message @difference, actual, Pact::RSpec.color_enabled?
16
17
  end
17
18
 
18
19
  end
@@ -0,0 +1,20 @@
1
+ module Pact
2
+ module RSpec
3
+
4
+ def self.color_enabled?
5
+ if ::RSpec.configuration.respond_to?(:color_enabled?)
6
+ ::RSpec.configuration.color_enabled?(::RSpec.configuration.output_stream)
7
+ else
8
+ ::RSpec.configuration.color_enabled?
9
+ end
10
+ end
11
+
12
+ def self.full_description example
13
+ example.respond_to?(:full_description) ? example.full_description : example.example.full_description
14
+ end
15
+
16
+ def self.runner_defined?
17
+ defined?(::RSpec::Core::Runner)
18
+ end
19
+ end
20
+ end
@@ -41,7 +41,7 @@ module Pact
41
41
  end
42
42
 
43
43
  def method_and_path
44
- "#{method.upcase} #{display_path}"
44
+ "#{method.upcase} #{full_path}"
45
45
  end
46
46
 
47
47
  def full_path
@@ -1,29 +1,32 @@
1
+ require 'pact/provider/pact_helper_locator'
2
+ require 'rake/file_utils'
3
+
1
4
  module Pact
2
5
  module TaskHelper
3
6
 
4
7
  extend self
5
8
 
9
+ def execute_pact_verify pact_uri = nil, pact_helper = nil
10
+ execute_cmd verify_command(pact_helper || Pact::Provider::PactHelperLocater.pact_helper_path, pact_uri)
11
+ end
12
+
6
13
  def handle_verification_failure
7
14
  exit_status = yield
8
15
  abort if exit_status != 0
9
16
  end
10
17
 
11
- def spec_criteria defaults = {description: nil, provider_state: nil}
12
- criteria = {}
13
-
14
- description = ENV.fetch("PACT_DESCRIPTION", defaults[:description])
15
- criteria[:description] = Regexp.new(description) if description
16
-
17
- provider_state = ENV.fetch("PACT_PROVIDER_STATE", defaults[:provider_state])
18
- if provider_state
19
- if provider_state.length == 0
20
- criteria[:provider_state] = nil #Allow PACT_PROVIDER_STATE="" to mean no provider state
21
- else
22
- criteria[:provider_state] = Regexp.new(provider_state)
23
- end
24
- end
18
+ def verify_command pact_helper, pact_uri = nil
19
+ command_parts = []
20
+ command_parts << FileUtils::RUBY
21
+ command_parts << "-S pact verify"
22
+ command_parts << "-h" << (pact_helper.end_with?(".rb") ? pact_helper : pact_helper + ".rb")
23
+ (command_parts << "-p" << pact_uri) if pact_uri
24
+ command_parts.flatten.join(" ")
25
+ end
25
26
 
26
- criteria
27
+ def execute_cmd command
28
+ system(command) ? 0 : 1
27
29
  end
30
+
28
31
  end
29
32
  end
@@ -1,7 +1,4 @@
1
1
  require 'rake/tasklib'
2
- require 'pact/provider/pact_spec_runner'
3
- require 'pact/provider/verification_report'
4
- require 'pact/tasks/task_helper'
5
2
 
6
3
  =begin
7
4
  To create a rake pact:verify:<something> task
@@ -30,58 +27,55 @@ require 'pact/tasks/task_helper'
30
27
 
31
28
  module Pact
32
29
  class VerificationTask < ::Rake::TaskLib
33
- attr_reader :pact_spec_config
34
30
 
35
- include Pact::TaskHelper
31
+ attr_reader :pact_spec_configs
32
+
36
33
  def initialize(name)
37
- @pact_spec_config = []
34
+ @pact_spec_configs = []
38
35
  @name = name
39
36
  yield self
40
37
  rake_task
41
38
  end
42
39
 
43
40
  def uri(uri, options = {})
44
- @pact_spec_config << {uri: uri, support_file: options[:support_file], pact_helper: options[:pact_helper]}
41
+ @pact_spec_configs << {uri: uri, pact_helper: options[:pact_helper]}
45
42
  end
46
43
 
47
44
  private
48
45
 
49
46
  attr_reader :name
50
47
 
51
- def parse_pactfile config
52
- Pact::ConsumerContract.from_uri config[:uri]
53
- end
48
+ # def parse_pactfile config
49
+ # Pact::ConsumerContract.from_uri config[:uri]
50
+ # end
54
51
 
55
- def publish_report config, output, result, provider_ref, reports_dir
56
- consumer_contract = parse_pactfile config
57
- #TODO - when checking out a historical version, provider ref will be prod, however it will think it is head. Fix this!!!!
58
- report = Provider::VerificationReport.new(
59
- :result => result,
60
- :output => output,
61
- :consumer => {:name => consumer_contract.consumer.name, :ref => name},
62
- :provider => {:name => consumer_contract.provider.name, :ref => provider_ref}
63
- )
64
-
65
- FileUtils.mkdir_p reports_dir
66
- File.open("#{reports_dir}/#{report.report_file_name}", "w") { |file| file << JSON.pretty_generate(report) }
67
- end
52
+ # def publish_report config, output, result, provider_ref, reports_dir
53
+ # consumer_contract = parse_pactfile config
54
+ # #TODO - when checking out a historical version, provider ref will be prod, however it will think it is head. Fix this!!!!
55
+ # report = Provider::VerificationReport.new(
56
+ # :result => result,
57
+ # :output => output,
58
+ # :consumer => {:name => consumer_contract.consumer.name, :ref => name},
59
+ # :provider => {:name => consumer_contract.provider.name, :ref => provider_ref}
60
+ # )
61
+
62
+ # FileUtils.mkdir_p reports_dir
63
+ # File.open("#{reports_dir}/#{report.report_file_name}", "w") { |file| file << JSON.pretty_generate(report) }
64
+ # end
68
65
 
69
66
  def rake_task
70
67
  namespace :pact do
68
+
71
69
  desc "Verify provider against the consumer pacts for #{name}"
72
- task "verify:#{name}", :description, :provider_state do |t, args|
70
+ task "verify:#{name}" do |t, args|
73
71
 
74
- options = {criteria: spec_criteria(args)}
72
+ require 'pact/tasks/task_helper'
75
73
 
76
- exit_statuses = pact_spec_config.collect do | config |
77
- #TODO: Change this to accept the ConsumerContract that is already parsed, so we don't make the same request twice
78
- pact_spec_runner = Provider::PactSpecRunner.new([config], options)
79
- exit_status = pact_spec_runner.run
80
- publish_report config, pact_spec_runner.output, exit_status == 0, 'head', Pact.configuration.reports_dir
81
- exit_status
74
+ exit_statuses = pact_spec_configs.collect do | config |
75
+ Pact::TaskHelper.execute_pact_verify config[:uri], config[:pact_helper]
82
76
  end
83
77
 
84
- handle_verification_failure do
78
+ Pact::TaskHelper.handle_verification_failure do
85
79
  exit_statuses.count{ | status | status != 0 }
86
80
  end
87
81
  end