pact 1.0.39 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +1 -17
- data/Gemfile.lock +2 -2
- data/README.md +18 -27
- data/bethtest.rb +30 -0
- data/documentation/faq.md +6 -36
- data/lib/pact/configuration.rb +0 -4
- data/lib/pact/consumer/consumer_contract_builder.rb +1 -1
- data/lib/pact/consumer_contract/active_support_support.rb +0 -4
- data/lib/pact/matchers/diff_decorator.rb +1 -1
- data/lib/pact/matchers/index_not_found.rb +12 -3
- data/lib/pact/matchers/matchers.rb +2 -1
- data/lib/pact/matchers/nested_json_diff_decorator.rb +48 -0
- data/lib/pact/matchers/plus_minus_diff_decorator.rb +92 -0
- data/lib/pact/matchers/unexpected_index.rb +13 -3
- data/lib/pact/matchers/unexpected_key.rb +12 -3
- data/lib/pact/provider/configuration.rb +31 -0
- data/lib/pact/provider/matchers.rb +4 -4
- data/lib/pact/provider/pact_spec_runner.rb +28 -35
- data/lib/pact/provider/print_missing_provider_states.rb +2 -2
- data/lib/pact/provider/rspec.rb +7 -16
- data/lib/pact/provider/world.rb +0 -6
- data/lib/pact/shared/key_not_found.rb +16 -3
- data/lib/pact/tasks/task_helper.rb +18 -15
- data/lib/pact/templates/provider_state.erb +1 -0
- data/lib/pact/version.rb +1 -1
- data/spec/lib/pact/matchers/matchers_spec.rb +9 -0
- data/spec/lib/pact/matchers/nested_json_diff_decorator_spec.rb +48 -0
- data/spec/lib/pact/matchers/plus_minus_diff_decorator_spec.rb +186 -0
- data/spec/lib/pact/provider/configuration_spec.rb +131 -102
- data/spec/lib/pact/verification_task_spec.rb +10 -0
- data/spec/support/pact_helper.rb +2 -5
- data/spec/support/stubbing.json +1 -1
- data/spec/support/test_app_fail.json +2 -29
- data/spec/support/test_app_pass.json +4 -4
- data/tasks/pact-test.rake +0 -8
- metadata +13 -22
- data/lib/pact/matchers/difference_indicator.rb +0 -26
- data/lib/pact/provider/rspec/formatter.rb +0 -63
- data/lib/pact/provider/rspec/silent_json_formatter.rb +0 -18
- data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
- data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
- data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
- data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
- data/spec/lib/pact/tasks/task_helper_spec.rb +0 -80
@@ -88,6 +88,16 @@ module Pact
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
context 'when one or more specs fail' do
|
92
|
+
|
93
|
+
let(:exit_code) {1}
|
94
|
+
|
95
|
+
it 'raises an exception' do
|
96
|
+
$stderr.should_receive(:puts) #Confusing if this shows on the screen!
|
97
|
+
expect { Rake::Task[@task_name].execute }.to raise_error RuntimeError
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
91
101
|
end
|
92
102
|
end
|
93
103
|
end
|
data/spec/support/pact_helper.rb
CHANGED
@@ -28,16 +28,12 @@ module Pact
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
Pact.set_up do
|
32
|
-
WEATHER ||= {}
|
33
|
-
end
|
34
31
|
|
35
32
|
#one with a top level consumer
|
36
33
|
Pact.provider_states_for 'some-test-consumer' do
|
37
|
-
|
38
34
|
provider_state "the weather is sunny" do
|
39
35
|
set_up do
|
40
|
-
|
36
|
+
WEATHER ||= {}
|
41
37
|
WEATHER[:current_state] = 'sunny'
|
42
38
|
end
|
43
39
|
end
|
@@ -46,6 +42,7 @@ module Pact
|
|
46
42
|
#one without a top level consumer
|
47
43
|
Pact.provider_state "the weather is cloudy" do
|
48
44
|
set_up do
|
45
|
+
WEATHER ||= {}
|
49
46
|
WEATHER[:current_state] = 'cloudy'
|
50
47
|
end
|
51
48
|
end
|
data/spec/support/stubbing.json
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
},
|
5
5
|
"provider": {
|
6
6
|
"name": "an unknown provider"
|
7
|
-
},
|
7
|
+
},
|
8
8
|
"interactions": [
|
9
9
|
{
|
10
|
-
"description": "
|
10
|
+
"description": "A test request",
|
11
11
|
"request": {
|
12
12
|
"method": "get",
|
13
13
|
"path": "/weather",
|
@@ -20,33 +20,6 @@
|
|
20
20
|
|
21
21
|
},
|
22
22
|
"provider_state": "the weather is cloudy"
|
23
|
-
},{
|
24
|
-
"description": "another test request",
|
25
|
-
"request": {
|
26
|
-
"method": "get",
|
27
|
-
"path": "/weather",
|
28
|
-
"query": ""
|
29
|
-
},
|
30
|
-
"response": {
|
31
|
-
"status": 200,
|
32
|
-
"headers" : {"Content-type": "application/json"},
|
33
|
-
"body": {"message" : "this is not the weather you are looking for"}
|
34
|
-
|
35
|
-
}
|
36
|
-
},{
|
37
|
-
"description": "another test request",
|
38
|
-
"provider_state": "a missing provider state",
|
39
|
-
"request": {
|
40
|
-
"method": "get",
|
41
|
-
"path": "/weather",
|
42
|
-
"query": ""
|
43
|
-
},
|
44
|
-
"response": {
|
45
|
-
"status": 200,
|
46
|
-
"headers" : {"Content-type": "application/json"},
|
47
|
-
"body": {"message" : "this is not the weather you are looking for"}
|
48
|
-
|
49
|
-
}
|
50
23
|
}
|
51
24
|
]
|
52
25
|
}
|
@@ -4,10 +4,10 @@
|
|
4
4
|
},
|
5
5
|
"provider": {
|
6
6
|
"name": "an unknown provider"
|
7
|
-
},
|
7
|
+
},
|
8
8
|
"interactions": [
|
9
9
|
{
|
10
|
-
"description": "
|
10
|
+
"description": "A test request",
|
11
11
|
"request": {
|
12
12
|
"method": "get",
|
13
13
|
"path": "/weather",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"provider_state": "the weather is sunny"
|
22
22
|
},
|
23
23
|
{
|
24
|
-
"description": "
|
24
|
+
"description": "A test request for text",
|
25
25
|
"request": {
|
26
26
|
"method": "get",
|
27
27
|
"path": "/sometext",
|
@@ -33,6 +33,6 @@
|
|
33
33
|
"headers" : {"Content-type": "text/plain"},
|
34
34
|
"body": "some text"
|
35
35
|
}
|
36
|
-
}
|
36
|
+
}
|
37
37
|
]
|
38
38
|
}
|
data/tasks/pact-test.rake
CHANGED
@@ -8,13 +8,6 @@ Pact::VerificationTask.new(:stubbing_using_allow) do | pact |
|
|
8
8
|
pact.uri './spec/support/stubbing.json', :pact_helper => './spec/support/stubbing_using_allow.rb'
|
9
9
|
end
|
10
10
|
|
11
|
-
Pact::VerificationTask.new(:pass) do | pact |
|
12
|
-
pact.uri './spec/support/test_app_pass.json'
|
13
|
-
end
|
14
|
-
|
15
|
-
Pact::VerificationTask.new(:fail) do | pact |
|
16
|
-
pact.uri './spec/support/test_app_fail.json'
|
17
|
-
end
|
18
11
|
|
19
12
|
namespace :pact do
|
20
13
|
|
@@ -27,7 +20,6 @@ namespace :pact do
|
|
27
20
|
silent = true
|
28
21
|
puts "Running task pact:tests"
|
29
22
|
# Run these specs silently, otherwise expected failures will be written to stdout and look like unexpected failures.
|
30
|
-
Pact.configuration.output_stream = StringIO.new if silent
|
31
23
|
|
32
24
|
result = Pact::Provider::PactSpecRunner.new([{ uri: './spec/support/test_app_pass.json' }], silent: silent).run
|
33
25
|
fail 'Expected pact to pass' unless (result == 0)
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Fraser
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-
|
16
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: randexp
|
@@ -295,6 +295,7 @@ files:
|
|
295
295
|
- LICENSE.txt
|
296
296
|
- README.md
|
297
297
|
- Rakefile
|
298
|
+
- bethtest.rb
|
298
299
|
- bin/pact
|
299
300
|
- config.ru
|
300
301
|
- documentation/Testing with pact.png
|
@@ -361,9 +362,10 @@ files:
|
|
361
362
|
- lib/pact/logging.rb
|
362
363
|
- lib/pact/matchers.rb
|
363
364
|
- lib/pact/matchers/diff_decorator.rb
|
364
|
-
- lib/pact/matchers/difference_indicator.rb
|
365
365
|
- lib/pact/matchers/index_not_found.rb
|
366
366
|
- lib/pact/matchers/matchers.rb
|
367
|
+
- lib/pact/matchers/nested_json_diff_decorator.rb
|
368
|
+
- lib/pact/matchers/plus_minus_diff_decorator.rb
|
367
369
|
- lib/pact/matchers/unexpected_index.rb
|
368
370
|
- lib/pact/matchers/unexpected_key.rb
|
369
371
|
- lib/pact/provider.rb
|
@@ -376,8 +378,6 @@ files:
|
|
376
378
|
- lib/pact/provider/print_missing_provider_states.rb
|
377
379
|
- lib/pact/provider/request.rb
|
378
380
|
- lib/pact/provider/rspec.rb
|
379
|
-
- lib/pact/provider/rspec/formatter.rb
|
380
|
-
- lib/pact/provider/rspec/silent_json_formatter.rb
|
381
381
|
- lib/pact/provider/state/provider_state.rb
|
382
382
|
- lib/pact/provider/state/provider_state_configured_modules.rb
|
383
383
|
- lib/pact/provider/state/provider_state_manager.rb
|
@@ -426,10 +426,9 @@ files:
|
|
426
426
|
- spec/lib/pact/consumer_contract/interaction_spec.rb
|
427
427
|
- spec/lib/pact/consumer_contract/request_spec.rb
|
428
428
|
- spec/lib/pact/matchers/diff_decorator_spec.rb
|
429
|
-
- spec/lib/pact/matchers/index_not_found_spec.rb
|
430
429
|
- spec/lib/pact/matchers/matchers_spec.rb
|
431
|
-
- spec/lib/pact/matchers/
|
432
|
-
- spec/lib/pact/matchers/
|
430
|
+
- spec/lib/pact/matchers/nested_json_diff_decorator_spec.rb
|
431
|
+
- spec/lib/pact/matchers/plus_minus_diff_decorator_spec.rb
|
433
432
|
- spec/lib/pact/provider/configuration_spec.rb
|
434
433
|
- spec/lib/pact/provider/pact_helper_locator_spec.rb
|
435
434
|
- spec/lib/pact/provider/pact_spec_runner_spec.rb
|
@@ -442,9 +441,7 @@ files:
|
|
442
441
|
- spec/lib/pact/provider/world_spec.rb
|
443
442
|
- spec/lib/pact/reification_spec.rb
|
444
443
|
- spec/lib/pact/shared/dsl_spec.rb
|
445
|
-
- spec/lib/pact/shared/key_not_found_spec.rb
|
446
444
|
- spec/lib/pact/something_like_spec.rb
|
447
|
-
- spec/lib/pact/tasks/task_helper_spec.rb
|
448
445
|
- spec/lib/pact/term_spec.rb
|
449
446
|
- spec/lib/pact/verification_task_spec.rb
|
450
447
|
- spec/spec_helper.rb
|
@@ -479,16 +476,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
479
476
|
version: '0'
|
480
477
|
segments:
|
481
478
|
- 0
|
482
|
-
hash:
|
479
|
+
hash: -3201059694268013519
|
483
480
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
484
481
|
none: false
|
485
482
|
requirements:
|
486
|
-
- - ! '
|
483
|
+
- - ! '>'
|
487
484
|
- !ruby/object:Gem::Version
|
488
|
-
version:
|
489
|
-
segments:
|
490
|
-
- 0
|
491
|
-
hash: 780584884635013301
|
485
|
+
version: 1.3.1
|
492
486
|
requirements: []
|
493
487
|
rubyforge_project:
|
494
488
|
rubygems_version: 1.8.23
|
@@ -523,10 +517,9 @@ test_files:
|
|
523
517
|
- spec/lib/pact/consumer_contract/interaction_spec.rb
|
524
518
|
- spec/lib/pact/consumer_contract/request_spec.rb
|
525
519
|
- spec/lib/pact/matchers/diff_decorator_spec.rb
|
526
|
-
- spec/lib/pact/matchers/index_not_found_spec.rb
|
527
520
|
- spec/lib/pact/matchers/matchers_spec.rb
|
528
|
-
- spec/lib/pact/matchers/
|
529
|
-
- spec/lib/pact/matchers/
|
521
|
+
- spec/lib/pact/matchers/nested_json_diff_decorator_spec.rb
|
522
|
+
- spec/lib/pact/matchers/plus_minus_diff_decorator_spec.rb
|
530
523
|
- spec/lib/pact/provider/configuration_spec.rb
|
531
524
|
- spec/lib/pact/provider/pact_helper_locator_spec.rb
|
532
525
|
- spec/lib/pact/provider/pact_spec_runner_spec.rb
|
@@ -539,9 +532,7 @@ test_files:
|
|
539
532
|
- spec/lib/pact/provider/world_spec.rb
|
540
533
|
- spec/lib/pact/reification_spec.rb
|
541
534
|
- spec/lib/pact/shared/dsl_spec.rb
|
542
|
-
- spec/lib/pact/shared/key_not_found_spec.rb
|
543
535
|
- spec/lib/pact/something_like_spec.rb
|
544
|
-
- spec/lib/pact/tasks/task_helper_spec.rb
|
545
536
|
- spec/lib/pact/term_spec.rb
|
546
537
|
- spec/lib/pact/verification_task_spec.rb
|
547
538
|
- spec/spec_helper.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'pact/consumer_contract/active_support_support'
|
2
|
-
|
3
|
-
module Pact
|
4
|
-
class DifferenceIndicator
|
5
|
-
|
6
|
-
include ActiveSupportSupport
|
7
|
-
|
8
|
-
def == other
|
9
|
-
other.is_a? self.class
|
10
|
-
end
|
11
|
-
|
12
|
-
def eql? other
|
13
|
-
self == other
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_json options = {}
|
17
|
-
remove_unicode as_json.to_json(options)
|
18
|
-
end
|
19
|
-
|
20
|
-
def as_json options = {}
|
21
|
-
to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'pact/provider/print_missing_provider_states'
|
2
|
-
require 'rspec/core/formatters'
|
3
|
-
require 'colored'
|
4
|
-
|
5
|
-
module Pact
|
6
|
-
module Provider
|
7
|
-
module RSpec
|
8
|
-
class Formatter < ::RSpec::Core::Formatters::DocumentationFormatter
|
9
|
-
|
10
|
-
|
11
|
-
def dump_commands_to_rerun_failed_examples
|
12
|
-
return if failed_examples.empty?
|
13
|
-
|
14
|
-
print_rerun_commands
|
15
|
-
print_failure_message
|
16
|
-
print_missing_provider_states
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def print_rerun_commands
|
21
|
-
output.puts("\n")
|
22
|
-
interaction_failure_messages.each do | message |
|
23
|
-
output.puts(message)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def print_missing_provider_states
|
28
|
-
PrintMissingProviderStates.call Pact.world.provider_states.missing_provider_states, output
|
29
|
-
end
|
30
|
-
|
31
|
-
def interaction_failure_messages
|
32
|
-
failed_examples.collect do |example|
|
33
|
-
interaction_failure_message_for example
|
34
|
-
end.uniq
|
35
|
-
end
|
36
|
-
|
37
|
-
def interaction_failure_message_for example
|
38
|
-
provider_state = example.metadata[:pact_interaction].provider_state
|
39
|
-
description = example.metadata[:pact_interaction].description
|
40
|
-
pactfile_uri = example.metadata[:pactfile_uri]
|
41
|
-
example_description = example.metadata[:pact_interaction_example_description]
|
42
|
-
failure_color("rake pact:verify:at[#{pactfile_uri}] PACT_DESCRIPTION=\"#{description}\" PACT_PROVIDER_STATE=\"#{provider_state}\"") + " " + detail_color("# #{example_description}")
|
43
|
-
end
|
44
|
-
|
45
|
-
def print_failure_message
|
46
|
-
output.puts failure_message
|
47
|
-
end
|
48
|
-
|
49
|
-
def failure_message
|
50
|
-
|
51
|
-
"\n" + "For assistance debugging failures, please note:".underline.yellow + "\n\n" +
|
52
|
-
"The pact files have been stored locally in the following temp directory:\n #{Pact.configuration.tmp_dir}\n\n" +
|
53
|
-
"The requests and responses are logged in the following log file:\n #{Pact.configuration.log_path}\n\n"
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rspec/core/formatters'
|
2
|
-
|
3
|
-
module Pact
|
4
|
-
module Provider
|
5
|
-
module RSpec
|
6
|
-
class SilentJsonFormatter < ::RSpec::Core::Formatters::JsonFormatter
|
7
|
-
|
8
|
-
def initialize stream
|
9
|
-
# Don't want to display this to the screen,
|
10
|
-
# not sure how else to set a custom stream for a particular formatter
|
11
|
-
# Store a reference to this so it can be inspected afterwards.
|
12
|
-
super(Pact.world.json_formatter_stream)
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pact/matchers/index_not_found'
|
3
|
-
|
4
|
-
module Pact
|
5
|
-
describe IndexNotFound do
|
6
|
-
|
7
|
-
describe "#as_json" do
|
8
|
-
it "returns a string representation of the object" do
|
9
|
-
expect(subject.as_json).to eq subject.to_s
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#to_json" do
|
14
|
-
it "serialises the object to JSON" do
|
15
|
-
expect(subject.to_json).to eq "\"#{subject.to_s}\""
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pact/matchers/unexpected_index'
|
3
|
-
|
4
|
-
module Pact
|
5
|
-
describe UnexpectedIndex do
|
6
|
-
|
7
|
-
describe "#as_json" do
|
8
|
-
it "returns a string representation of the object" do
|
9
|
-
expect(subject.as_json).to eq subject.to_s
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#to_json" do
|
14
|
-
it "serialises the object to JSON" do
|
15
|
-
expect(subject.to_json).to eq "\"#{subject.to_s}\""
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pact/matchers/unexpected_key'
|
3
|
-
|
4
|
-
module Pact
|
5
|
-
describe UnexpectedKey do
|
6
|
-
|
7
|
-
describe "#as_json" do
|
8
|
-
it "returns a string representation of the object" do
|
9
|
-
expect(subject.as_json).to eq subject.to_s
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#to_json" do
|
14
|
-
it "serialises the object to JSON" do
|
15
|
-
expect(subject.to_json).to eq "\"#{subject.to_s}\""
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pact/shared/key_not_found'
|
3
|
-
|
4
|
-
module Pact
|
5
|
-
describe KeyNotFound do
|
6
|
-
|
7
|
-
describe "#as_json" do
|
8
|
-
it "returns a string representation of the object" do
|
9
|
-
expect(subject.as_json).to eq subject.to_s
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#to_json" do
|
14
|
-
it "serialises the object to JSON" do
|
15
|
-
expect(subject.to_json).to eq "\"#{subject.to_s}\""
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|