pact 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +31 -20
- data/Gemfile.lock +12 -12
- data/README.md +32 -16
- data/Rakefile +3 -3
- data/documentation/README.md +1 -0
- data/documentation/development-workflow.md +22 -0
- data/documentation/faq.md +8 -0
- data/documentation/provider-states.md +2 -0
- data/documentation/troubleshooting.md +4 -0
- data/documentation/verifying-pacts.md +97 -0
- data/lib/pact/app.rb +98 -4
- data/lib/pact/consumer/rspec.rb +3 -2
- data/lib/pact/doc/doc_file.rb +4 -4
- data/lib/pact/doc/generator.rb +3 -3
- data/lib/pact/doc/interaction_view_model.rb +1 -0
- data/lib/pact/doc/markdown/{interactions_renderer.rb → consumer_contract_renderer.rb} +1 -1
- data/lib/pact/doc/markdown/generator.rb +2 -2
- data/lib/pact/matchers/unix_diff_formatter.rb +1 -1
- data/lib/pact/project_root.rb +7 -0
- data/lib/pact/provider.rb +0 -1
- data/lib/pact/provider/context.rb +0 -0
- data/lib/pact/provider/matchers/messages.rb +15 -13
- data/lib/pact/provider/pact_spec_runner.rb +21 -22
- data/lib/pact/provider/rspec.rb +22 -15
- data/lib/pact/provider/rspec/custom_options_file +0 -0
- data/lib/pact/provider/{matchers.rb → rspec/matchers.rb} +2 -1
- data/lib/pact/rspec.rb +20 -0
- data/lib/pact/shared/request.rb +1 -1
- data/lib/pact/tasks/task_helper.rb +18 -15
- data/lib/pact/tasks/verification_task.rb +26 -32
- data/lib/pact/version.rb +1 -1
- data/lib/tasks/pact.rake +5 -11
- data/spec/integration/pact/consumer_configuration_spec.rb +3 -3
- data/spec/lib/pact/app_spec.rb +47 -0
- data/spec/lib/pact/consumer/app_manager_spec.rb +1 -1
- data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +3 -3
- data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +10 -2
- data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +2 -2
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +1 -1
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +4 -4
- data/spec/lib/pact/consumer_contract/request_spec.rb +23 -23
- data/spec/lib/pact/doc/generator_spec.rb +4 -4
- data/spec/lib/pact/doc/markdown/{interactions_renderer_spec.rb → consumer_contract_renderer_spec.rb} +4 -4
- data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +8 -8
- data/spec/lib/pact/provider/configuration/configuration_extension_spec.rb +2 -2
- data/spec/lib/pact/provider/matchers/messages_spec.rb +17 -6
- data/spec/lib/pact/provider/rspec/formatter_spec.rb +3 -1
- data/spec/lib/pact/shared/dsl_spec.rb +1 -1
- data/spec/lib/pact/shared/request_spec.rb +8 -0
- data/spec/lib/pact/tasks/task_helper_spec.rb +39 -54
- data/spec/lib/pact/tasks/verification_task_spec.rb +75 -0
- data/spec/pact_specification/compliance-1.0.0.rb +47 -0
- data/spec/spec_helper.rb +2 -6
- data/spec/standalone/consumer_fail_test.rb +1 -0
- data/spec/standalone/consumer_pass_test.rb +1 -0
- data/spec/support/active_support_if_configured.rb +6 -0
- data/spec/support/pact_helper.rb +2 -1
- data/spec/support/shared_examples_for_request.rb +15 -4
- data/spec/support/spec_support.rb +3 -0
- data/spec/support/stubbing_using_allow.rb +1 -0
- data/spec/support/term.json +13 -1
- data/tasks/pact-test.rake +45 -26
- metadata +23 -13
- data/lib/pact/provider/client_project_pact_helper.rb +0 -4
- data/spec/lib/pact/provider/pact_spec_runner_spec.rb +0 -7
- data/spec/lib/pact/verification_task_spec.rb +0 -99
data/spec/spec_helper.rb
CHANGED
@@ -6,15 +6,11 @@ require 'pact'
|
|
6
6
|
require 'webmock/rspec'
|
7
7
|
require_relative 'support/factories'
|
8
8
|
require_relative 'support/spec_support'
|
9
|
+
require 'pact/provider/rspec'
|
9
10
|
|
10
11
|
WebMock.disable_net_connect!(allow_localhost: true)
|
11
12
|
|
12
|
-
|
13
|
-
puts 'LOADING ACTIVE SUPPORT!!!! Hopefully it all still works'
|
14
|
-
require 'active_support/all'
|
15
|
-
require 'active_support'
|
16
|
-
require 'active_support/json'
|
17
|
-
end
|
13
|
+
require './spec/support/active_support_if_configured'
|
18
14
|
|
19
15
|
RSpec.configure do | config |
|
20
16
|
config.include(FakeFS::SpecHelpers, :fakefs => true)
|
data/spec/support/pact_helper.rb
CHANGED
@@ -59,10 +59,21 @@ shared_examples "a request" do
|
|
59
59
|
|
60
60
|
subject { described_class.from_hash(raw_request) }
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
it "extracts the method" do
|
63
|
+
expect(subject.method).to eq 'get'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "extracts the path" do
|
67
|
+
expect(subject.path).to eq '/mallory'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "extracts the body" do
|
71
|
+
expect(subject.body).to eq 'hello mallory'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "extracts the query" do
|
75
|
+
expect(subject.query).to eq 'query'
|
76
|
+
end
|
66
77
|
|
67
78
|
it "blows up if method is absent" do
|
68
79
|
raw_request.delete 'method'
|
data/spec/support/term.json
CHANGED
@@ -15,7 +15,19 @@
|
|
15
15
|
},
|
16
16
|
"response": {
|
17
17
|
"status": 200,
|
18
|
-
"headers" : {
|
18
|
+
"headers" : {
|
19
|
+
"Content-type": {
|
20
|
+
"json_class": "Pact::Term",
|
21
|
+
"data": {
|
22
|
+
"generate": "text/plain",
|
23
|
+
"matcher": {
|
24
|
+
"json_class": "Regexp",
|
25
|
+
"o": 0,
|
26
|
+
"s": "text"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
19
31
|
"body": {
|
20
32
|
"message" : {
|
21
33
|
"json_class": "Pact::Term",
|
data/tasks/pact-test.rake
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require 'pact/tasks'
|
1
|
+
require 'pact/tasks/verification_task'
|
2
|
+
require 'open3'
|
2
3
|
|
3
4
|
Pact::VerificationTask.new(:stubbing) do | pact |
|
4
|
-
pact.uri './spec/support/stubbing.json', :pact_helper => './spec/support/stubbing
|
5
|
+
pact.uri './spec/support/stubbing.json', :pact_helper => './spec/support/stubbing'
|
5
6
|
end
|
6
7
|
|
7
8
|
Pact::VerificationTask.new(:stubbing_using_allow) do | pact |
|
@@ -13,6 +14,7 @@ Pact::VerificationTask.new(:pass) do | pact |
|
|
13
14
|
end
|
14
15
|
|
15
16
|
Pact::VerificationTask.new(:fail) do | pact |
|
17
|
+
pact.uri './spec/support/test_app_pass.json'
|
16
18
|
pact.uri './spec/support/test_app_fail.json'
|
17
19
|
end
|
18
20
|
|
@@ -28,49 +30,66 @@ RSpec::Core::RakeTask.new('spec:standalone:pass') do | task |
|
|
28
30
|
task.pattern = FileList["spec/standalone/**/*_pass_test.rb"]
|
29
31
|
end
|
30
32
|
|
33
|
+
Pact::VerificationTask.new('test_app:pass') do | pact |
|
34
|
+
pact.uri './spec/support/test_app_pass.json'
|
35
|
+
end
|
36
|
+
|
37
|
+
Pact::VerificationTask.new('test_app:fail') do | pact |
|
38
|
+
pact.uri './spec/support/test_app_fail.json', pact_helper: './spec/support/pact_helper.rb'
|
39
|
+
end
|
40
|
+
|
41
|
+
task :bethtest => ['pact:tests:all','pact:tests:all:with_active_support']
|
42
|
+
|
31
43
|
namespace :pact do
|
32
44
|
|
45
|
+
desc "All the verification tests"
|
46
|
+
task "tests:all" do
|
47
|
+
Rake::Task['pact:verify:stubbing'].execute
|
48
|
+
Rake::Task['pact:verify:stubbing_using_allow'].execute
|
49
|
+
Rake::Task['spec:standalone:pass'].execute
|
50
|
+
Rake::Task['pact:verify'].execute
|
51
|
+
Rake::Task['pact:verify:test_app:pass'].execute
|
52
|
+
Rake::Task['pact:test:fail'].execute
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "All the verification tests with active support loaded"
|
56
|
+
task 'tests:all:with_active_support' => :set_active_support_on do
|
57
|
+
Rake::Task['pact:tests:all'].execute
|
58
|
+
end
|
59
|
+
|
33
60
|
desc 'Runs pact tests against a sample application, testing failure and success.'
|
34
|
-
task
|
61
|
+
task 'test:fail' do
|
35
62
|
|
36
|
-
require 'pact/provider/pact_spec_runner'
|
37
63
|
require 'open3'
|
38
64
|
|
39
65
|
silent = true
|
40
|
-
puts "Running task pact:tests"
|
41
66
|
# Run these specs silently, otherwise expected failures will be written to stdout and look like unexpected failures.
|
42
|
-
Pact.configuration.output_stream = StringIO.new if silent
|
43
|
-
|
44
|
-
result = Pact::Provider::PactSpecRunner.new([{ uri: './spec/support/test_app_pass.json' }], silent: silent).run
|
45
|
-
fail 'Expected pact to pass' unless (result == 0)
|
46
|
-
|
47
|
-
result = Pact::Provider::PactSpecRunner.new([{ uri: './spec/support/test_app_fail.json', pact_helper: './spec/support/pact_helper.rb' }], silent: silent).run
|
48
|
-
fail 'Expected pact to fail' if (result == 0)
|
49
|
-
|
50
|
-
expect_to_pass "bundle exec rake pact:verify"
|
51
|
-
expect_to_pass "bundle exec rake pact:verify:at[./spec/support/test_app_pass.json]"
|
52
|
-
expect_to_fail "bundle exec rake pact:verify:at[./spec/support/test_app_fail.json]"
|
53
|
-
expect_to_fail "bundle exec rake spec:standalone:fail"
|
67
|
+
#Pact.configuration.output_stream = StringIO.new if silent
|
54
68
|
|
55
|
-
|
69
|
+
expect_to_fail "bundle exec rake pact:verify:test_app:fail", with: [/Could not find one or more provider states/]
|
70
|
+
expect_to_fail "bundle exec rake spec:standalone:fail", with: [/Actual interactions do not match expected interactions/]
|
71
|
+
expect_to_fail "bundle exec rake pact:verify:term", with: [%r{"Content-type" with value /text/}]
|
56
72
|
end
|
57
73
|
|
58
|
-
def expect_to_fail command
|
59
|
-
success = execute_command command
|
74
|
+
def expect_to_fail command, options = {}
|
75
|
+
success = execute_command command, options
|
60
76
|
fail "Expected '#{command}' to fail" if success
|
61
77
|
end
|
62
78
|
|
63
|
-
def
|
64
|
-
success = execute_command command
|
65
|
-
fail "Expected '#{command}' to pass" unless success
|
66
|
-
end
|
67
|
-
|
68
|
-
def execute_command command
|
79
|
+
def execute_command command, options
|
69
80
|
result = nil
|
70
81
|
Open3.popen3(command) {|stdin, stdout, stderr, wait_thr|
|
71
82
|
result = wait_thr.value
|
83
|
+
ensure_patterns_present(options, stdout, stderr) if options[:with]
|
72
84
|
}
|
73
85
|
result.success?
|
74
86
|
end
|
75
87
|
|
88
|
+
def ensure_patterns_present options, stdout, stderr
|
89
|
+
output = stdout.read + stderr.read
|
90
|
+
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
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
76
95
|
end
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-
|
16
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: randexp
|
@@ -302,6 +302,7 @@ files:
|
|
302
302
|
- documentation/Testing with pact.png
|
303
303
|
- documentation/best-practices.md
|
304
304
|
- documentation/configuration.md
|
305
|
+
- documentation/development-workflow.md
|
305
306
|
- documentation/diff_formatter_embedded.png
|
306
307
|
- documentation/diff_formatter_list.png
|
307
308
|
- documentation/diff_formatter_unix.png
|
@@ -309,6 +310,8 @@ files:
|
|
309
310
|
- documentation/provider-states.md
|
310
311
|
- documentation/raq.md
|
311
312
|
- documentation/terminology.md
|
313
|
+
- documentation/troubleshooting.md
|
314
|
+
- documentation/verifying-pacts.md
|
312
315
|
- example/animal-service/Gemfile
|
313
316
|
- example/animal-service/Gemfile.lock
|
314
317
|
- example/animal-service/Rakefile
|
@@ -375,11 +378,11 @@ files:
|
|
375
378
|
- lib/pact/doc/generate.rb
|
376
379
|
- lib/pact/doc/generator.rb
|
377
380
|
- lib/pact/doc/interaction_view_model.rb
|
381
|
+
- lib/pact/doc/markdown/consumer_contract_renderer.rb
|
378
382
|
- lib/pact/doc/markdown/generator.rb
|
379
383
|
- lib/pact/doc/markdown/index_renderer.rb
|
380
384
|
- lib/pact/doc/markdown/interaction.erb
|
381
385
|
- lib/pact/doc/markdown/interaction_renderer.rb
|
382
|
-
- lib/pact/doc/markdown/interactions_renderer.rb
|
383
386
|
- lib/pact/doc/sort_interactions.rb
|
384
387
|
- lib/pact/logging.rb
|
385
388
|
- lib/pact/matchers.rb
|
@@ -399,15 +402,15 @@ files:
|
|
399
402
|
- lib/pact/matchers/unexpected_index.rb
|
400
403
|
- lib/pact/matchers/unexpected_key.rb
|
401
404
|
- lib/pact/matchers/unix_diff_formatter.rb
|
405
|
+
- lib/pact/project_root.rb
|
402
406
|
- lib/pact/provider.rb
|
403
|
-
- lib/pact/provider/client_project_pact_helper.rb
|
404
407
|
- lib/pact/provider/configuration.rb
|
405
408
|
- lib/pact/provider/configuration/configuration_extension.rb
|
406
409
|
- lib/pact/provider/configuration/dsl.rb
|
407
410
|
- lib/pact/provider/configuration/pact_verification.rb
|
408
411
|
- lib/pact/provider/configuration/service_provider_config.rb
|
409
412
|
- lib/pact/provider/configuration/service_provider_dsl.rb
|
410
|
-
- lib/pact/provider/
|
413
|
+
- lib/pact/provider/context.rb
|
411
414
|
- lib/pact/provider/matchers/messages.rb
|
412
415
|
- lib/pact/provider/pact_helper_locator.rb
|
413
416
|
- lib/pact/provider/pact_spec_runner.rb
|
@@ -415,7 +418,9 @@ files:
|
|
415
418
|
- lib/pact/provider/print_missing_provider_states.rb
|
416
419
|
- lib/pact/provider/request.rb
|
417
420
|
- lib/pact/provider/rspec.rb
|
421
|
+
- lib/pact/provider/rspec/custom_options_file
|
418
422
|
- lib/pact/provider/rspec/formatter.rb
|
423
|
+
- lib/pact/provider/rspec/matchers.rb
|
419
424
|
- lib/pact/provider/rspec/silent_json_formatter.rb
|
420
425
|
- lib/pact/provider/state/provider_state.rb
|
421
426
|
- lib/pact/provider/state/provider_state_configured_modules.rb
|
@@ -425,6 +430,7 @@ files:
|
|
425
430
|
- lib/pact/provider/verification_report.rb
|
426
431
|
- lib/pact/provider/world.rb
|
427
432
|
- lib/pact/reification.rb
|
433
|
+
- lib/pact/rspec.rb
|
428
434
|
- lib/pact/shared/active_support_support.rb
|
429
435
|
- lib/pact/shared/dsl.rb
|
430
436
|
- lib/pact/shared/jruby_support.rb
|
@@ -448,6 +454,7 @@ files:
|
|
448
454
|
- spec/integration/consumer_spec.rb
|
449
455
|
- spec/integration/pact/consumer_configuration_spec.rb
|
450
456
|
- spec/integration/pact/provider_configuration_spec.rb
|
457
|
+
- spec/lib/pact/app_spec.rb
|
451
458
|
- spec/lib/pact/configuration_spec.rb
|
452
459
|
- spec/lib/pact/consumer/app_manager_spec.rb
|
453
460
|
- spec/lib/pact/consumer/configuration_spec.rb
|
@@ -469,8 +476,8 @@ files:
|
|
469
476
|
- spec/lib/pact/consumer_contract/request_spec.rb
|
470
477
|
- spec/lib/pact/doc/generator_spec.rb
|
471
478
|
- spec/lib/pact/doc/interaction_view_model_spec.rb
|
479
|
+
- spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb
|
472
480
|
- spec/lib/pact/doc/markdown/index_renderer_spec.rb
|
473
|
-
- spec/lib/pact/doc/markdown/interactions_renderer_spec.rb
|
474
481
|
- spec/lib/pact/matchers/differ_spec.rb
|
475
482
|
- spec/lib/pact/matchers/difference_spec.rb
|
476
483
|
- spec/lib/pact/matchers/embedded_diff_formatter_spec.rb
|
@@ -489,7 +496,6 @@ files:
|
|
489
496
|
- spec/lib/pact/provider/configuration_spec.rb
|
490
497
|
- spec/lib/pact/provider/matchers/messages_spec.rb
|
491
498
|
- spec/lib/pact/provider/pact_helper_locator_spec.rb
|
492
|
-
- spec/lib/pact/provider/pact_spec_runner_spec.rb
|
493
499
|
- spec/lib/pact/provider/print_missing_provider_states_spec.rb
|
494
500
|
- spec/lib/pact/provider/request_spec.rb
|
495
501
|
- spec/lib/pact/provider/rspec/formatter_spec.rb
|
@@ -504,13 +510,15 @@ files:
|
|
504
510
|
- spec/lib/pact/shared/request_spec.rb
|
505
511
|
- spec/lib/pact/something_like_spec.rb
|
506
512
|
- spec/lib/pact/tasks/task_helper_spec.rb
|
513
|
+
- spec/lib/pact/tasks/verification_task_spec.rb
|
507
514
|
- spec/lib/pact/term_spec.rb
|
508
|
-
- spec/
|
515
|
+
- spec/pact_specification/compliance-1.0.0.rb
|
509
516
|
- spec/spec_helper.rb
|
510
517
|
- spec/standalone/consumer_fail_test.rb
|
511
518
|
- spec/standalone/consumer_pass_test.rb
|
512
519
|
- spec/support/a_consumer-a_producer.json
|
513
520
|
- spec/support/a_consumer-a_provider.json
|
521
|
+
- spec/support/active_support_if_configured.rb
|
514
522
|
- spec/support/app_for_config_ru.rb
|
515
523
|
- spec/support/consumer_contract_template.json
|
516
524
|
- spec/support/dsl_spec_support.rb
|
@@ -547,7 +555,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
547
555
|
version: '0'
|
548
556
|
segments:
|
549
557
|
- 0
|
550
|
-
hash:
|
558
|
+
hash: 3393348357730131022
|
551
559
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
552
560
|
none: false
|
553
561
|
requirements:
|
@@ -556,7 +564,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
556
564
|
version: '0'
|
557
565
|
segments:
|
558
566
|
- 0
|
559
|
-
hash:
|
567
|
+
hash: 3393348357730131022
|
560
568
|
requirements: []
|
561
569
|
rubyforge_project:
|
562
570
|
rubygems_version: 1.8.23
|
@@ -572,6 +580,7 @@ test_files:
|
|
572
580
|
- spec/integration/consumer_spec.rb
|
573
581
|
- spec/integration/pact/consumer_configuration_spec.rb
|
574
582
|
- spec/integration/pact/provider_configuration_spec.rb
|
583
|
+
- spec/lib/pact/app_spec.rb
|
575
584
|
- spec/lib/pact/configuration_spec.rb
|
576
585
|
- spec/lib/pact/consumer/app_manager_spec.rb
|
577
586
|
- spec/lib/pact/consumer/configuration_spec.rb
|
@@ -593,8 +602,8 @@ test_files:
|
|
593
602
|
- spec/lib/pact/consumer_contract/request_spec.rb
|
594
603
|
- spec/lib/pact/doc/generator_spec.rb
|
595
604
|
- spec/lib/pact/doc/interaction_view_model_spec.rb
|
605
|
+
- spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb
|
596
606
|
- spec/lib/pact/doc/markdown/index_renderer_spec.rb
|
597
|
-
- spec/lib/pact/doc/markdown/interactions_renderer_spec.rb
|
598
607
|
- spec/lib/pact/matchers/differ_spec.rb
|
599
608
|
- spec/lib/pact/matchers/difference_spec.rb
|
600
609
|
- spec/lib/pact/matchers/embedded_diff_formatter_spec.rb
|
@@ -613,7 +622,6 @@ test_files:
|
|
613
622
|
- spec/lib/pact/provider/configuration_spec.rb
|
614
623
|
- spec/lib/pact/provider/matchers/messages_spec.rb
|
615
624
|
- spec/lib/pact/provider/pact_helper_locator_spec.rb
|
616
|
-
- spec/lib/pact/provider/pact_spec_runner_spec.rb
|
617
625
|
- spec/lib/pact/provider/print_missing_provider_states_spec.rb
|
618
626
|
- spec/lib/pact/provider/request_spec.rb
|
619
627
|
- spec/lib/pact/provider/rspec/formatter_spec.rb
|
@@ -628,13 +636,15 @@ test_files:
|
|
628
636
|
- spec/lib/pact/shared/request_spec.rb
|
629
637
|
- spec/lib/pact/something_like_spec.rb
|
630
638
|
- spec/lib/pact/tasks/task_helper_spec.rb
|
639
|
+
- spec/lib/pact/tasks/verification_task_spec.rb
|
631
640
|
- spec/lib/pact/term_spec.rb
|
632
|
-
- spec/
|
641
|
+
- spec/pact_specification/compliance-1.0.0.rb
|
633
642
|
- spec/spec_helper.rb
|
634
643
|
- spec/standalone/consumer_fail_test.rb
|
635
644
|
- spec/standalone/consumer_pass_test.rb
|
636
645
|
- spec/support/a_consumer-a_producer.json
|
637
646
|
- spec/support/a_consumer-a_provider.json
|
647
|
+
- spec/support/active_support_if_configured.rb
|
638
648
|
- spec/support/app_for_config_ru.rb
|
639
649
|
- spec/support/consumer_contract_template.json
|
640
650
|
- spec/support/dsl_spec_support.rb
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'pact/tasks/verification_task'
|
3
|
-
|
4
|
-
module Pact
|
5
|
-
describe VerificationTask do
|
6
|
-
before :all do
|
7
|
-
@support_file = nil
|
8
|
-
@pact_helper = '/custom/path/support_file.rb'
|
9
|
-
@pact_uri = 'http://example.org/pact.json'
|
10
|
-
@task_name = 'pact:verify:pact_rake_spec'
|
11
|
-
@task_name_with_explict_support_file = 'pact:verify:pact_rake_spec_with_explict_support_file'
|
12
|
-
@consumer = 'some-consumer'
|
13
|
-
@criteria = {:description => /wiffle/}
|
14
|
-
|
15
|
-
VerificationTask.new(:pact_rake_spec_with_explict_support_file) do | pact |
|
16
|
-
pact.uri @pact_uri, support_file: @support_file, pact_helper: @pact_helper
|
17
|
-
end
|
18
|
-
|
19
|
-
VerificationTask.new(:pact_rake_spec) do | pact |
|
20
|
-
pact.uri @pact_uri
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
after :each do
|
25
|
-
ENV.delete 'PACT_DESCRIPTION'
|
26
|
-
end
|
27
|
-
|
28
|
-
before do
|
29
|
-
ENV['PACT_DESCRIPTION'] = 'wiffle'
|
30
|
-
VerificationTask.any_instance.stub(:publish_report)
|
31
|
-
Provider::PactSpecRunner.stub(:new).with(consumer_contract, options).and_return(pact_spec_runner)
|
32
|
-
end
|
33
|
-
|
34
|
-
let(:pact_spec_runner) { double('PactSpecRunner', :run => exit_code, :output => nil)}
|
35
|
-
let(:exit_code) {0}
|
36
|
-
let(:consumer_contract) { [ uri: @pact_uri, support_file: nil, pact_helper: nil ] }
|
37
|
-
let(:options) { {criteria: @criteria} }
|
38
|
-
|
39
|
-
|
40
|
-
describe '.initialize' do
|
41
|
-
context 'with an explict support_file' do
|
42
|
-
it 'creates the tasks' do
|
43
|
-
Rake::Task.tasks.should include_task @task_name
|
44
|
-
end
|
45
|
-
end
|
46
|
-
context 'with no explict support_file' do
|
47
|
-
it 'creates the tasks' do
|
48
|
-
Rake::Task.tasks.should include_task @task_name_with_explict_support_file
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'execute' do
|
54
|
-
|
55
|
-
|
56
|
-
context "with no explicit support file " do
|
57
|
-
it 'verifies the pacts using PactSpecRunner' do
|
58
|
-
Rake::Task[@task_name].execute
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "with an explict support_file" do
|
63
|
-
let(:consumer_contract) { [ uri: @pact_uri, support_file: @support_file, pact_helper: @pact_helper] }
|
64
|
-
it 'verifies the pacts using PactSpecRunner' do
|
65
|
-
Rake::Task[@task_name_with_explict_support_file].execute
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with criteria" do
|
70
|
-
it 'passes the criteria to the PactSpecRunner as regexes' do
|
71
|
-
ENV.delete 'PACT_DESCRIPTION'
|
72
|
-
Provider::PactSpecRunner.should_receive(:new).with(
|
73
|
-
consumer_contract, {
|
74
|
-
criteria: {
|
75
|
-
description: /stuff/,
|
76
|
-
provider_state: /things/
|
77
|
-
}
|
78
|
-
}
|
79
|
-
).and_return(pact_spec_runner)
|
80
|
-
Rake::Task[@task_name].execute(description: 'stuff', provider_state: 'things')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'when all specs pass' do
|
85
|
-
|
86
|
-
it 'does not raise an exception' do
|
87
|
-
Rake::Task[@task_name].execute
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
RSpec::Matchers.define :include_task do |expected|
|
96
|
-
match do |actual|
|
97
|
-
actual.any? { |task| task.name == expected }
|
98
|
-
end
|
99
|
-
end
|