pact 1.1.1 → 1.2.1.rc1

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 (69) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/Gemfile.lock +42 -39
  3. data/README.md +2 -0
  4. data/documentation/configuration.md +2 -2
  5. data/documentation/faq.md +5 -7
  6. data/documentation/provider-states.md +2 -10
  7. data/example/animal-service/spec/service_consumers/pact_helper.rb +0 -4
  8. data/lib/pact/consumer/configuration/mock_service.rb +2 -0
  9. data/lib/pact/consumer/consumer_contract_builder.rb +58 -58
  10. data/lib/pact/consumer/mock_service/app.rb +4 -1
  11. data/lib/pact/consumer/mock_service/interaction_replay.rb +11 -3
  12. data/lib/pact/consumer/mock_service/missing_interactions_get.rb +2 -2
  13. data/lib/pact/consumer/mock_service/pact_post.rb +33 -0
  14. data/lib/pact/consumer/mock_service/verification_get.rb +1 -2
  15. data/lib/pact/consumer/mock_service_client.rb +14 -5
  16. data/lib/pact/consumer/mock_service_interaction_expectation.rb +1 -1
  17. data/lib/pact/consumer/spec_hooks.rb +2 -0
  18. data/lib/pact/consumer/world.rb +25 -0
  19. data/lib/pact/consumer_contract/consumer_contract.rb +1 -1
  20. data/lib/pact/consumer_contract/consumer_contract_writer.rb +84 -0
  21. data/lib/pact/consumer_contract/file_name.rb +7 -1
  22. data/lib/pact/provider/pact_helper_locator.rb +1 -1
  23. data/lib/pact/provider/pact_spec_runner.rb +3 -9
  24. data/lib/pact/provider/rspec/{formatter.rb → formatter_rspec_2.rb} +2 -2
  25. data/lib/pact/provider/rspec/formatter_rspec_3.rb +96 -0
  26. data/lib/pact/provider/rspec/matchers.rb +79 -19
  27. data/lib/pact/provider/rspec.rb +3 -1
  28. data/lib/pact/provider/state/provider_state_configured_modules.rb +6 -0
  29. data/lib/pact/provider/state/provider_state_manager.rb +3 -3
  30. data/lib/pact/provider/world.rb +2 -8
  31. data/lib/pact/rspec.rb +32 -0
  32. data/lib/pact/version.rb +1 -1
  33. data/pact.gemspec +3 -3
  34. data/spec/features/consumption_spec.rb +6 -1
  35. data/spec/integration/consumer_spec.rb +16 -9
  36. data/spec/integration/pact/consumer_configuration_spec.rb +7 -22
  37. data/spec/lib/pact/app_spec.rb +5 -5
  38. data/spec/lib/pact/configuration_spec.rb +1 -1
  39. data/spec/lib/pact/consumer/app_manager_spec.rb +3 -3
  40. data/spec/lib/pact/consumer/configuration_spec.rb +11 -8
  41. data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +3 -101
  42. data/spec/lib/pact/consumer/interaction_builder_spec.rb +8 -8
  43. data/spec/lib/pact/consumer/mock_service/app_spec.rb +2 -2
  44. data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +2 -2
  45. data/spec/lib/pact/consumer/mock_service/interaction_replay_spec.rb +12 -0
  46. data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +2 -2
  47. data/spec/lib/pact/consumer/mock_service_client_spec.rb +88 -0
  48. data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +4 -4
  49. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +18 -18
  50. data/spec/lib/pact/consumer_contract/consumer_contract_writer_spec.rb +111 -0
  51. data/spec/lib/pact/provider/configuration/pact_verification_spec.rb +1 -1
  52. data/spec/lib/pact/provider/pact_helper_locator_spec.rb +2 -2
  53. data/spec/lib/pact/provider/rspec/{formatter_spec.rb → formatter_rspec_2_spec.rb} +14 -4
  54. data/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb +72 -0
  55. data/spec/lib/pact/provider/rspec_spec.rb +3 -0
  56. data/spec/lib/pact/provider/state/provider_state_manager_spec.rb +1 -1
  57. data/spec/lib/pact/provider/state/provider_state_proxy_spec.rb +4 -4
  58. data/spec/lib/pact/provider/state/provider_state_spec.rb +7 -7
  59. data/spec/lib/pact/provider/world_spec.rb +8 -8
  60. data/spec/lib/pact/tasks/verification_task_spec.rb +2 -2
  61. data/spec/spec_helper.rb +2 -4
  62. data/spec/support/factories.rb +13 -13
  63. data/spec/support/spec_support.rb +10 -0
  64. data/spec/support/stubbing_using_allow.rb +0 -4
  65. data/tasks/pact-test.rake +12 -8
  66. metadata +27 -24
  67. data/bethtest.rb +0 -30
  68. data/lib/pact/provider/rspec/silent_json_formatter.rb +0 -18
  69. data/spec/support/stubbing.rb +0 -26
@@ -0,0 +1,111 @@
1
+ require 'spec_helper'
2
+ require 'pact/consumer_contract/consumer_contract_writer'
3
+
4
+ module Pact
5
+
6
+ describe ConsumerContractWriter do
7
+
8
+ let(:support_pact_file) { './spec/support/a_consumer-a_provider.json' }
9
+ let(:consumer_name) { 'a consumer' }
10
+ let(:provider_name) { 'a provider' }
11
+
12
+ before do
13
+ Pact.clear_configuration
14
+ allow(Pact.configuration).to receive(:pact_dir).and_return(File.expand_path(tmp_pact_dir))
15
+ FileUtils.rm_rf tmp_pact_dir
16
+ FileUtils.mkdir_p tmp_pact_dir
17
+ FileUtils.cp support_pact_file, "#{tmp_pact_dir}/a_consumer-a_provider.json"
18
+ end
19
+
20
+ let(:existing_interactions) { ConsumerContract.from_json(File.read(support_pact_file)).interactions }
21
+ let(:new_interactions) { [InteractionFactory.create] }
22
+ let(:tmp_pact_dir) {"./tmp/pacts"}
23
+ let(:logger) { double("logger").as_null_object }
24
+ let(:pactfile_write_mode) {:overwrite}
25
+ let(:consumer_contract_details) {
26
+ {
27
+ consumer: {name: consumer_name},
28
+ provider: {name: provider_name},
29
+ pactfile_write_mode: pactfile_write_mode,
30
+ interactions: new_interactions
31
+ }
32
+ }
33
+
34
+ let(:consumer_contract_writer) { ConsumerContractWriter.new(consumer_contract_details, logger) }
35
+
36
+ describe "consumer_contract" do
37
+
38
+ let(:subject) { consumer_contract_writer.consumer_contract }
39
+
40
+ context "when overwriting pact" do
41
+
42
+ it "it uses only the interactions from the current test run" do
43
+ expect(consumer_contract_writer.consumer_contract.interactions).to eq new_interactions
44
+ end
45
+
46
+ end
47
+
48
+ context "when updating pact" do
49
+
50
+ let(:pactfile_write_mode) {:update}
51
+
52
+ it "merges the interactions from the current test run with the interactions from the existing file" do
53
+ allow_any_instance_of(ConsumerContractWriter).to receive(:info_and_puts)
54
+ expect(consumer_contract_writer.consumer_contract.interactions).to eq existing_interactions + new_interactions
55
+ end
56
+
57
+ let(:line0) { /\*/ }
58
+ let(:line1) { /Updating existing file/ }
59
+ let(:line2) { /Only interactions defined in this test run will be updated/ }
60
+ let(:line3) { /As interactions are identified by description and provider state/ }
61
+
62
+ it "logs a description message" do
63
+ expect($stdout).to receive(:puts).with(line0).twice
64
+ expect($stdout).to receive(:puts).with(line1)
65
+ expect($stdout).to receive(:puts).with(line2)
66
+ expect($stdout).to receive(:puts).with(line3)
67
+ expect(logger).to receive(:info).with(line0).twice
68
+ expect(logger).to receive(:info).with(line1)
69
+ expect(logger).to receive(:info).with(line2)
70
+ expect(logger).to receive(:info).with(line3)
71
+ consumer_contract_writer.consumer_contract
72
+ end
73
+ end
74
+
75
+ context "when an error occurs deserializing the existing pactfile" do
76
+
77
+ let(:pactfile_write_mode) {:update}
78
+ let(:error) { RuntimeError.new('some error')}
79
+ let(:line1) { /Could not load existing consumer contract from .* due to some error/ }
80
+ let(:line2) {'Creating a new file.'}
81
+
82
+ before do
83
+ allow(ConsumerContract).to receive(:from_json).and_raise(error)
84
+ allow($stderr).to receive(:puts)
85
+ allow(logger).to receive(:puts)
86
+ end
87
+
88
+ it "logs the error" do
89
+ expect($stderr).to receive(:puts).with(line1)
90
+ expect($stderr).to receive(:puts).with(line2)
91
+ expect(logger).to receive(:warn).with(line1)
92
+ expect(logger).to receive(:warn).with(line2)
93
+ consumer_contract_writer.consumer_contract
94
+ end
95
+
96
+ it "uses the new interactions" do
97
+ expect(consumer_contract_writer.consumer_contract.interactions).to eq new_interactions
98
+ end
99
+ end
100
+ end
101
+
102
+ describe "write" do
103
+ it "writes the pact file" do
104
+ expect_any_instance_of(ConsumerContract).to receive(:update_pactfile)
105
+ consumer_contract_writer.write
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+ end
@@ -20,7 +20,7 @@ module Pact
20
20
  end
21
21
 
22
22
  it "creates a Verification" do
23
- Pact::Provider::PactVerification.should_receive(:new).with(consumer_name, url, ref)
23
+ expect(Pact::Provider::PactVerification).to receive(:new).with(consumer_name, url, ref)
24
24
  subject
25
25
  end
26
26
  end
@@ -29,7 +29,7 @@ module Pact::Provider
29
29
  context "the pact_helper is stored in #{dir}" do
30
30
  it "finds the pact_helper" do
31
31
  make_pactfile dir
32
- expect(subject).to eq "#{Dir.pwd}#{dir}/pact_helper.rb"
32
+ expect(subject).to eq File.join(Dir.pwd, dir, 'pact_helper.rb')
33
33
  end
34
34
  end
35
35
  end
@@ -38,7 +38,7 @@ module Pact::Provider
38
38
  it "returns the one that matches the most explict search pattern" do
39
39
  make_pactfile '/spec/consumer'
40
40
  FileUtils.touch 'pact_helper.rb'
41
- expect(subject).to eq "#{Dir.pwd}/spec/consumer/pact_helper.rb"
41
+ expect(subject).to eq File.join(Dir.pwd, '/spec/consumer/pact_helper.rb')
42
42
  end
43
43
  end
44
44
 
@@ -1,12 +1,22 @@
1
1
  require 'spec_helper'
2
- require 'pact/provider/rspec/formatter'
2
+ require 'pact/provider/rspec/formatter_rspec_2'
3
3
  require './spec/support/factories'
4
4
  require './spec/support/spec_support'
5
5
 
6
6
  module Pact
7
7
  module Provider
8
8
  module RSpec
9
- describe Formatter do
9
+ describe Formatter2 do
10
+
11
+ Pact::RSpec.with_rspec_3 do
12
+
13
+ # These methods don't exist in RSpec3
14
+ class Formatter2
15
+ def failure_color arg ; arg; end
16
+ def detail_color arg ; arg; end
17
+ end
18
+
19
+ end
10
20
 
11
21
  let(:interaction) { InteractionFactory.create 'provider_state' => 'a state', 'description' => 'a description'}
12
22
  let(:pactfile_uri) { 'pact_file_uri' }
@@ -18,14 +28,14 @@ module Pact
18
28
  let(:rerun_command) { "rake pact:verify:at[pact_file_uri] PACT_DESCRIPTION=\"a description\" PACT_PROVIDER_STATE=\"a state\" # an interaction" }
19
29
  let(:missing_provider_states) { 'missing_provider_states'}
20
30
 
21
- subject { Formatter.new output }
31
+ subject { Formatter2.new output }
22
32
 
23
33
  let(:output_result) { Pact::SpecSupport.remove_ansicolor output.string }
24
34
 
25
35
  before do
26
36
  allow(PrintMissingProviderStates).to receive(:call)
27
37
  allow(subject).to receive(:failed_examples).and_return(failed_examples)
28
- allow(Pact.world.provider_states).to receive(:missing_provider_states).and_return(missing_provider_states)
38
+ allow(Pact.provider_world.provider_states).to receive(:missing_provider_states).and_return(missing_provider_states)
29
39
  subject.dump_commands_to_rerun_failed_examples
30
40
  end
31
41
 
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'pact/provider/rspec/formatter_rspec_3'
3
+ require './spec/support/factories'
4
+ require './spec/support/spec_support'
5
+
6
+ Pact::RSpec.with_rspec_3 do
7
+ module Pact
8
+ module Provider
9
+ module RSpec
10
+ describe Formatter do
11
+
12
+ let(:interaction) { InteractionFactory.create 'provider_state' => 'a state', 'description' => 'a description'}
13
+ let(:pactfile_uri) { 'pact_file_uri' }
14
+ let(:description) { 'an interaction' }
15
+ let(:metadata) { {pact_interaction: interaction, pactfile_uri: pactfile_uri, pact_interaction_example_description: description}}
16
+ let(:metadata_2) { metadata.merge(pact_interaction_example_description: 'another interaction')}
17
+ let(:example) { double("Example", metadata: metadata) }
18
+ let(:example_2) { double("Example", metadata: metadata_2) }
19
+ let(:failed_examples) { [example, example] }
20
+ let(:examples) { [example, example, example_2]}
21
+ let(:output) { StringIO.new }
22
+ let(:rerun_command) { "rake pact:verify:at[pact_file_uri] PACT_DESCRIPTION=\"a description\" PACT_PROVIDER_STATE=\"a state\" # an interaction" }
23
+ let(:missing_provider_states) { 'missing_provider_states'}
24
+ let(:summary) { double("summary", failure_count: 1, failed_examples: failed_examples, examples: examples)}
25
+
26
+ subject { Formatter.new output }
27
+
28
+ let(:output_result) { Pact::SpecSupport.remove_ansicolor output.string }
29
+
30
+ before do
31
+ allow(PrintMissingProviderStates).to receive(:call)
32
+ allow(subject).to receive(:failed_examples).and_return(failed_examples)
33
+ allow(Pact.provider_world.provider_states).to receive(:missing_provider_states).and_return(missing_provider_states)
34
+ subject.dump_summary summary
35
+ end
36
+
37
+ describe "#dump_summary" do
38
+ it "prints a list of rerun commands" do
39
+ expect(output_result).to include(rerun_command)
40
+ end
41
+
42
+ it "only prints unique commands" do
43
+ expect(output_result.scan(rerun_command).size).to eq 1
44
+ end
45
+
46
+ it "prints a message about the logs" do
47
+ expect(output_result).to include("For assistance debugging failures")
48
+ end
49
+
50
+ it "prints the number of interactions" do
51
+ expect(output_result).to include("2 interactions")
52
+ end
53
+
54
+ it "prints the number of failures" do
55
+ expect(output_result).to include("1 failure")
56
+ end
57
+
58
+ it "prints missing provider states" do
59
+ expect(PrintMissingProviderStates).to receive(:call).with(missing_provider_states, output)
60
+ subject.dump_summary summary
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+
72
+
@@ -1,7 +1,10 @@
1
1
  require 'pact/provider/rspec'
2
+ require 'pact/provider/rspec/matchers'
2
3
 
3
4
  describe "the match_term matcher" do
4
5
 
6
+ include Pact::RSpec::Matchers
7
+
5
8
  it 'does not match a hash to an array' do
6
9
  expect({}).to_not match_term([])
7
10
  end
@@ -10,7 +10,7 @@ module Pact::Provider::State
10
10
 
11
11
  before do
12
12
  PROVIDER_STATE_MESSAGES.clear
13
- Pact.clear_world
13
+ Pact.clear_provider_world
14
14
 
15
15
  Pact.set_up do
16
16
  PROVIDER_STATE_MESSAGES << :global_base_set_up
@@ -16,13 +16,13 @@ module Pact
16
16
  subject { provider_state_proxy.get name, options }
17
17
 
18
18
  before do
19
- ProviderStates.stub(:get).and_return(provider_state)
19
+ allow(ProviderStates).to receive(:get).and_return(provider_state)
20
20
  end
21
21
 
22
22
  context "when the provider state exists" do
23
23
 
24
24
  it "retrieves the provider state from ProviderState" do
25
- ProviderStates.should_receive(:get).with(name, options).and_return(provider_state)
25
+ expect(ProviderStates).to receive(:get).with(name, options).and_return(provider_state)
26
26
  subject
27
27
  end
28
28
 
@@ -61,13 +61,13 @@ module Pact
61
61
  describe "get_base" do
62
62
 
63
63
  before do
64
- ProviderStates.stub(:get_base).and_return(provider_state)
64
+ allow(ProviderStates).to receive(:get_base).and_return(provider_state)
65
65
  end
66
66
 
67
67
  subject { provider_state_proxy.get_base options }
68
68
 
69
69
  it "calls through to ProviderStates" do
70
- ProviderStates.should_receive(:get_base).with(options)
70
+ expect(ProviderStates).to receive(:get_base).with(options)
71
71
  subject
72
72
  end
73
73
 
@@ -33,26 +33,26 @@ module Pact
33
33
  describe 'set_up' do
34
34
  it 'should call the block passed to set_up' do
35
35
  subject.set_up
36
- MESSAGES.should eq ['set_up']
36
+ expect(MESSAGES).to eq ['set_up']
37
37
  end
38
38
  end
39
39
 
40
40
  describe 'tear_down' do
41
41
  it 'should call the block passed to set_up' do
42
42
  subject.tear_down
43
- MESSAGES.should eq ['tear_down']
43
+ expect(MESSAGES).to eq ['tear_down']
44
44
  end
45
45
  end
46
46
 
47
47
  describe '.get' do
48
48
  context 'when the name is a matching symbol' do
49
49
  it 'will return the ProviderState' do
50
- ProviderStates.get('no_alligators').should_not be_nil
50
+ expect(ProviderStates.get('no_alligators')).to_not be_nil
51
51
  end
52
52
  end
53
53
  context 'when the name is a matching string' do
54
54
  it 'will return the ProviderState' do
55
- ProviderStates.get('some alligators').should_not be_nil
55
+ expect(ProviderStates.get('some alligators')).to_not be_nil
56
56
  end
57
57
  end
58
58
  end
@@ -121,11 +121,11 @@ module Pact
121
121
  describe '.get' do
122
122
  context 'for a consumer' do
123
123
  it 'has a namespaced name' do
124
- ProviderStates.get('the weather is sunny', :for => 'a consumer').should_not be_nil
124
+ expect(ProviderStates.get('the weather is sunny', :for => 'a consumer')).to_not be_nil
125
125
  end
126
126
 
127
127
  it 'falls back to a global state of the same name if one is not found for the specified consumer' do
128
- ProviderStates.get('the weather is cloudy', :for => 'a consumer').should_not be_nil
128
+ expect(ProviderStates.get('the weather is cloudy', :for => 'a consumer')).to_not be_nil
129
129
  end
130
130
  end
131
131
 
@@ -135,7 +135,7 @@ module Pact
135
135
  context 'for a consumer' do
136
136
  it 'runs its own setup' do
137
137
  ProviderStates.get('the weather is sunny', :for => 'a consumer').set_up
138
- NAMESPACED_MESSAGES.should eq ['sunny!']
138
+ expect(NAMESPACED_MESSAGES).to eq ['sunny!']
139
139
  end
140
140
  end
141
141
  end
@@ -1,21 +1,21 @@
1
1
  require 'spec_helper'
2
- require 'pact/provider/world'
2
+ load 'pact/provider/world.rb'
3
3
 
4
4
  describe Pact do
5
- describe ".world" do
5
+ describe ".provider_world" do
6
6
  it "returns a world" do
7
- expect(Pact.world).to be_instance_of Pact::Provider::World
7
+ expect(Pact.provider_world).to be_instance_of Pact::Provider::World
8
8
  end
9
9
  it "returns the same world each time" do
10
- expect(Pact.world).to be Pact.world
10
+ expect(Pact.provider_world).to be Pact.provider_world
11
11
  end
12
12
  end
13
13
 
14
- describe ".clear_world" do
14
+ describe ".clear_provider_world" do
15
15
  it "clears the world" do
16
- original_world = Pact.world
17
- Pact.clear_world
18
- expect(original_world).to_not be Pact.world
16
+ original_world = Pact.provider_world
17
+ Pact.clear_provider_world
18
+ expect(original_world).to_not be Pact.provider_world
19
19
  end
20
20
  end
21
21
 
@@ -30,12 +30,12 @@ module Pact
30
30
  describe '.initialize' do
31
31
  context 'with an explict pact_helper' do
32
32
  it 'creates the tasks' do
33
- Rake::Task.tasks.should include_task @task_name
33
+ expect(Rake::Task.tasks).to include_task @task_name
34
34
  end
35
35
  end
36
36
  context 'with no explict pact_helper' do
37
37
  it 'creates the tasks' do
38
- Rake::Task.tasks.should include_task @task_name_with_explict_pact_helper
38
+ expect(Rake::Task.tasks).to include_task @task_name_with_explict_pact_helper
39
39
  end
40
40
  end
41
41
  end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,10 @@
1
1
  require 'rspec'
2
- require 'rspec/fire'
3
2
  require 'fakefs/spec_helpers'
4
3
  require 'rspec'
5
4
  require 'pact'
6
5
  require 'webmock/rspec'
7
- require_relative 'support/factories'
8
- require_relative 'support/spec_support'
6
+ require 'support/factories'
7
+ require 'support/spec_support'
9
8
  require 'pact/provider/rspec'
10
9
 
11
10
  WebMock.disable_net_connect!(allow_localhost: true)
@@ -14,7 +13,6 @@ require './spec/support/active_support_if_configured'
14
13
 
15
14
  RSpec.configure do | config |
16
15
  config.include(FakeFS::SpecHelpers, :fakefs => true)
17
- config.include(RSpec::Fire)
18
16
 
19
17
  config.extend Pact::Provider::RSpec::ClassMethods
20
18
  config.include Pact::Provider::RSpec::InstanceMethods
@@ -27,20 +27,20 @@ class InteractionFactory
27
27
 
28
28
  extend Pact::HashUtils
29
29
 
30
- DEFAULTS = Hash[
31
- 'request' => {
32
- 'path' => '/path',
33
- 'method' => 'get',
34
- },
35
- 'response' => {
36
- 'body' => {a: 'response body'}
37
- },
38
- 'description' => 'a description',
39
- 'provider_state' => 'a thing exists'
40
- ]
41
-
42
30
  def self.create hash = {}
43
- Pact::Interaction.from_hash(stringify_keys(deep_merge(DEFAULTS, stringify_keys(hash))))
31
+ defaults = {
32
+ 'description' => 'a description',
33
+ 'provider_state' => 'a thing exists',
34
+ 'request' => {
35
+ 'path' => '/path',
36
+ 'method' => 'get',
37
+ },
38
+ 'response' => {
39
+ 'status' => 200,
40
+ 'body' => {a: 'response body'}
41
+ }
42
+ }
43
+ Pact::Interaction.from_hash(stringify_keys(deep_merge(defaults, stringify_keys(hash))))
44
44
  end
45
45
  end
46
46
 
@@ -1,3 +1,5 @@
1
+ require 'pact/rspec'
2
+
1
3
  module Pact
2
4
  module SpecSupport
3
5
 
@@ -6,5 +8,13 @@ module Pact
6
8
  def remove_ansicolor string
7
9
  string.gsub(/\e\[(\d+)m/, '')
8
10
  end
11
+
12
+ Pact::RSpec.with_rspec_2 do
13
+
14
+ def instance_double *args
15
+ double(*args)
16
+ end
17
+
18
+ end
9
19
  end
10
20
  end
@@ -24,10 +24,6 @@ end
24
24
  # Include the ExampleMethods module after the provider states are declared
25
25
  # to ensure the ordering doesn't matter
26
26
 
27
- Pact.configure do | config |
28
- config.include RSpec::Mocks::ExampleMethods
29
- end
30
-
31
27
  Pact.service_provider 'Provider' do
32
28
  app { App }
33
29
  end
data/tasks/pact-test.rake CHANGED
@@ -2,10 +2,6 @@ require 'pact/tasks/verification_task'
2
2
  require 'open3'
3
3
 
4
4
  Pact::VerificationTask.new(:stubbing) do | pact |
5
- pact.uri './spec/support/stubbing.json', :pact_helper => './spec/support/stubbing'
6
- end
7
-
8
- Pact::VerificationTask.new(:stubbing_using_allow) do | pact |
9
5
  pact.uri './spec/support/stubbing.json', :pact_helper => './spec/support/stubbing_using_allow.rb'
10
6
  end
11
7
 
@@ -45,7 +41,6 @@ namespace :pact do
45
41
  desc "All the verification tests"
46
42
  task "tests:all" do
47
43
  Rake::Task['pact:verify:stubbing'].execute
48
- Rake::Task['pact:verify:stubbing_using_allow'].execute
49
44
  Rake::Task['spec:standalone:pass'].execute
50
45
  Rake::Task['pact:verify'].execute
51
46
  Rake::Task['pact:verify:test_app:pass'].execute
@@ -57,6 +52,14 @@ namespace :pact do
57
52
  Rake::Task['pact:tests:all'].execute
58
53
  end
59
54
 
55
+ desc "Ensure pact file is written"
56
+ task 'test:pactfile' do
57
+ pact_path = './spec/pacts/standalone_consumer-standalone_provider.json'
58
+ FileUtils.rm_rf pact_path
59
+ Rake::Task['spec:standalone:pass'].execute
60
+ fail "Did not find expected pact file at #{pact_path}" unless File.exist?(pact_path)
61
+ end
62
+
60
63
  desc 'Runs pact tests against a sample application, testing failure and success.'
61
64
  task 'test:fail' do
62
65
 
@@ -80,15 +83,16 @@ namespace :pact do
80
83
  result = nil
81
84
  Open3.popen3(command) {|stdin, stdout, stderr, wait_thr|
82
85
  result = wait_thr.value
83
- ensure_patterns_present(options, stdout, stderr) if options[:with]
86
+ ensure_patterns_present(command, options, stdout, stderr) if options[:with]
84
87
  }
85
88
  result.success?
86
89
  end
87
90
 
88
- def ensure_patterns_present options, stdout, stderr
91
+ def ensure_patterns_present command, options, stdout, stderr
92
+ require 'term/ansicolor'
89
93
  output = stdout.read + stderr.read
90
94
  options[:with].each do | pattern |
91
- raise (::Term::ANSIColor.red("Could not find #{pattern.inspect} in output of #{command}").red + "\n\n#{output}") unless output =~ pattern
95
+ raise (::Term::ANSIColor.red("Could not find #{pattern.inspect} in output of #{command}") + "\n\n#{output}") unless output =~ pattern
92
96
  end
93
97
  end
94
98