pact 1.3.3 → 1.4.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.
- data/CHANGELOG.md +37 -1
- data/lib/pact/cli.rb +0 -26
- data/lib/pact/consumer/configuration/configuration_extensions.rb +51 -0
- data/lib/pact/consumer/configuration/mock_service.rb +2 -1
- data/lib/pact/consumer/configuration.rb +0 -1
- data/lib/pact/consumer/consumer_contract_builder.rb +3 -3
- data/lib/pact/consumer/interaction_builder.rb +3 -5
- data/lib/pact/doc/interaction_view_model.rb +9 -6
- data/lib/pact/doc/sort_interactions.rb +1 -1
- data/lib/pact/provider/configuration/configuration_extension.rb +0 -9
- data/lib/pact/provider/rspec.rb +11 -9
- data/lib/pact/version.rb +1 -1
- data/lib/pact.rb +6 -5
- data/pact.gemspec +6 -2
- metadata +57 -304
- data/.gitignore +0 -29
- data/.rspec +0 -2
- data/.ruby-version +0 -1
- data/.travis.yml +0 -8
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -86
- data/README.md +0 -313
- data/Rakefile +0 -9
- data/config.ru +0 -3
- data/documentation/README.md +0 -13
- data/documentation/configuration.md +0 -166
- data/documentation/diff_formatter_embedded.png +0 -0
- data/documentation/diff_formatter_list.png +0 -0
- data/documentation/diff_formatter_unix.png +0 -0
- data/example/animal-service/Gemfile +0 -14
- data/example/animal-service/Gemfile.lock +0 -69
- data/example/animal-service/Rakefile +0 -5
- data/example/animal-service/config.ru +0 -3
- data/example/animal-service/db/animal_db.sqlite3 +0 -0
- data/example/animal-service/lib/animal_service/animal_repository.rb +0 -12
- data/example/animal-service/lib/animal_service/api.rb +0 -28
- data/example/animal-service/lib/animal_service/db.rb +0 -5
- data/example/animal-service/spec/service_consumers/pact_helper.rb +0 -11
- data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +0 -26
- data/example/zoo-app/Gemfile +0 -12
- data/example/zoo-app/Gemfile.lock +0 -63
- data/example/zoo-app/Rakefile +0 -5
- data/example/zoo-app/doc/pacts/markdown/README.md +0 -3
- data/example/zoo-app/doc/pacts/markdown/Zoo App - Animal Service.md +0 -75
- data/example/zoo-app/lib/zoo_app/animal_service_client.rb +0 -40
- data/example/zoo-app/lib/zoo_app/models/alligator.rb +0 -15
- data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +0 -67
- data/example/zoo-app/spec/service_providers/animal_service_client_spec.rb +0 -71
- data/example/zoo-app/spec/service_providers/pact_helper.rb +0 -15
- data/example/zoo-app/spec/spec_helper.rb +0 -6
- data/lib/pact/configuration.rb +0 -195
- data/lib/pact/consumer/app_manager.rb +0 -158
- data/lib/pact/consumer/interactions_filter.rb +0 -48
- data/lib/pact/consumer/mock_service/app.rb +0 -82
- data/lib/pact/consumer/mock_service/interaction_delete.rb +0 -33
- data/lib/pact/consumer/mock_service/interaction_list.rb +0 -76
- data/lib/pact/consumer/mock_service/interaction_mismatch.rb +0 -73
- data/lib/pact/consumer/mock_service/interaction_post.rb +0 -31
- data/lib/pact/consumer/mock_service/interaction_replay.rb +0 -139
- data/lib/pact/consumer/mock_service/log_get.rb +0 -28
- data/lib/pact/consumer/mock_service/missing_interactions_get.rb +0 -30
- data/lib/pact/consumer/mock_service/mock_service_administration_endpoint.rb +0 -31
- data/lib/pact/consumer/mock_service/pact_post.rb +0 -33
- data/lib/pact/consumer/mock_service/rack_request_helper.rb +0 -51
- data/lib/pact/consumer/mock_service/verification_get.rb +0 -68
- data/lib/pact/consumer/mock_service.rb +0 -2
- data/lib/pact/consumer/mock_service_client.rb +0 -65
- data/lib/pact/consumer/mock_service_interaction_expectation.rb +0 -37
- data/lib/pact/consumer/request.rb +0 -27
- data/lib/pact/consumer/server.rb +0 -90
- data/lib/pact/consumer_contract/consumer_contract.rb +0 -115
- data/lib/pact/consumer_contract/consumer_contract_writer.rb +0 -84
- data/lib/pact/consumer_contract/file_name.rb +0 -19
- data/lib/pact/consumer_contract/headers.rb +0 -51
- data/lib/pact/consumer_contract/interaction.rb +0 -67
- data/lib/pact/consumer_contract/pact_file.rb +0 -24
- data/lib/pact/consumer_contract/request.rb +0 -73
- data/lib/pact/consumer_contract/service_consumer.rb +0 -28
- data/lib/pact/consumer_contract/service_provider.rb +0 -28
- data/lib/pact/consumer_contract.rb +0 -1
- data/lib/pact/logging.rb +0 -14
- data/lib/pact/matchers/actual_type.rb +0 -16
- data/lib/pact/matchers/base_difference.rb +0 -37
- data/lib/pact/matchers/differ.rb +0 -153
- data/lib/pact/matchers/difference.rb +0 -13
- data/lib/pact/matchers/difference_indicator.rb +0 -26
- data/lib/pact/matchers/embedded_diff_formatter.rb +0 -62
- data/lib/pact/matchers/expected_type.rb +0 -35
- data/lib/pact/matchers/index_not_found.rb +0 -15
- data/lib/pact/matchers/list_diff_formatter.rb +0 -101
- data/lib/pact/matchers/matchers.rb +0 -139
- data/lib/pact/matchers/no_diff_indicator.rb +0 -18
- data/lib/pact/matchers/regexp_difference.rb +0 -13
- data/lib/pact/matchers/type_difference.rb +0 -16
- data/lib/pact/matchers/unexpected_index.rb +0 -11
- data/lib/pact/matchers/unexpected_key.rb +0 -11
- data/lib/pact/matchers/unix_diff_formatter.rb +0 -114
- data/lib/pact/matchers.rb +0 -1
- data/lib/pact/reification.rb +0 -28
- data/lib/pact/rspec.rb +0 -53
- data/lib/pact/shared/active_support_support.rb +0 -51
- data/lib/pact/shared/dsl.rb +0 -76
- data/lib/pact/shared/jruby_support.rb +0 -18
- data/lib/pact/shared/json_differ.rb +0 -15
- data/lib/pact/shared/key_not_found.rb +0 -15
- data/lib/pact/shared/null_expectation.rb +0 -31
- data/lib/pact/shared/request.rb +0 -80
- data/lib/pact/shared/text_differ.rb +0 -14
- data/lib/pact/something_like.rb +0 -49
- data/lib/pact/symbolize_keys.rb +0 -12
- data/lib/pact/term.rb +0 -85
- data/scratchpad.rb +0 -52
- data/spec/features/consumption_spec.rb +0 -114
- data/spec/features/production_spec.rb +0 -155
- data/spec/features/provider_states/zebras.rb +0 -28
- data/spec/integration/consumer_spec.rb +0 -212
- data/spec/integration/pact/consumer_configuration_spec.rb +0 -66
- data/spec/integration/pact/provider_configuration_spec.rb +0 -25
- data/spec/lib/pact/cli_spec.rb +0 -47
- data/spec/lib/pact/configuration_spec.rb +0 -297
- data/spec/lib/pact/consumer/app_manager_spec.rb +0 -41
- data/spec/lib/pact/consumer/configuration_spec.rb +0 -57
- data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +0 -69
- data/spec/lib/pact/consumer/interaction_builder_spec.rb +0 -91
- data/spec/lib/pact/consumer/interactions_spec.rb +0 -64
- data/spec/lib/pact/consumer/mock_service/app_spec.rb +0 -52
- data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +0 -78
- data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +0 -70
- data/spec/lib/pact/consumer/mock_service/interaction_replay_spec.rb +0 -12
- data/spec/lib/pact/consumer/mock_service/rack_request_helper_spec.rb +0 -88
- data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +0 -142
- data/spec/lib/pact/consumer/mock_service_client_spec.rb +0 -88
- data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +0 -54
- data/spec/lib/pact/consumer/request_spec.rb +0 -24
- data/spec/lib/pact/consumer/service_consumer_spec.rb +0 -11
- data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -180
- data/spec/lib/pact/consumer_contract/consumer_contract_writer_spec.rb +0 -111
- data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -107
- data/spec/lib/pact/consumer_contract/request_spec.rb +0 -329
- data/spec/lib/pact/doc/generator_spec.rb +0 -84
- data/spec/lib/pact/doc/interaction_view_model_spec.rb +0 -132
- data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +0 -29
- data/spec/lib/pact/doc/markdown/index_renderer_spec.rb +0 -29
- data/spec/lib/pact/matchers/differ_spec.rb +0 -214
- data/spec/lib/pact/matchers/difference_spec.rb +0 -22
- data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
- data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
- data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -114
- data/spec/lib/pact/matchers/matchers_spec.rb +0 -500
- data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
- data/spec/lib/pact/matchers/type_difference_spec.rb +0 -34
- 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/matchers/unix_diff_formatter_spec.rb +0 -216
- data/spec/lib/pact/provider/configuration/configuration_extension_spec.rb +0 -30
- data/spec/lib/pact/provider/configuration/pact_verification_spec.rb +0 -43
- data/spec/lib/pact/provider/configuration/service_provider_config_spec.rb +0 -21
- data/spec/lib/pact/provider/configuration/service_provider_dsl_spec.rb +0 -108
- data/spec/lib/pact/provider/configuration_spec.rb +0 -50
- data/spec/lib/pact/provider/matchers/messages_spec.rb +0 -116
- data/spec/lib/pact/provider/pact_helper_locator_spec.rb +0 -54
- data/spec/lib/pact/provider/print_missing_provider_states_spec.rb +0 -19
- data/spec/lib/pact/provider/request_spec.rb +0 -78
- data/spec/lib/pact/provider/rspec/formatter_rspec_2_spec.rb +0 -68
- data/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb +0 -72
- data/spec/lib/pact/provider/rspec_spec.rb +0 -55
- data/spec/lib/pact/provider/state/provider_state_manager_spec.rb +0 -89
- data/spec/lib/pact/provider/state/provider_state_proxy_spec.rb +0 -80
- data/spec/lib/pact/provider/state/provider_state_spec.rb +0 -213
- data/spec/lib/pact/provider/world_spec.rb +0 -41
- data/spec/lib/pact/reification_spec.rb +0 -67
- data/spec/lib/pact/shared/dsl_spec.rb +0 -86
- data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
- data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
- data/spec/lib/pact/shared/request_spec.rb +0 -111
- data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
- data/spec/lib/pact/something_like_spec.rb +0 -21
- data/spec/lib/pact/tasks/task_helper_spec.rb +0 -74
- data/spec/lib/pact/tasks/verification_task_spec.rb +0 -75
- data/spec/lib/pact/term_spec.rb +0 -89
- data/spec/pact_specification/compliance-1.0.0.rb +0 -47
- data/spec/spec_helper.rb +0 -22
- data/spec/standalone/consumer_fail_test.rb +0 -55
- data/spec/standalone/consumer_pass_test.rb +0 -51
- data/spec/support/a_consumer-a_producer.json +0 -32
- data/spec/support/a_consumer-a_provider.json +0 -32
- data/spec/support/active_support_if_configured.rb +0 -6
- data/spec/support/app_for_config_ru.rb +0 -4
- data/spec/support/consumer_contract_template.json +0 -24
- data/spec/support/dsl_spec_support.rb +0 -7
- data/spec/support/factories.rb +0 -82
- data/spec/support/generated_index.md +0 -4
- data/spec/support/generated_markdown.md +0 -55
- data/spec/support/interaction_view_model.json +0 -63
- data/spec/support/interaction_view_model_with_terms.json +0 -50
- data/spec/support/markdown_pact.json +0 -48
- data/spec/support/missing_provider_states_output.txt +0 -25
- data/spec/support/options.json +0 -21
- data/spec/support/options_app.rb +0 -15
- data/spec/support/pact_helper.rb +0 -57
- data/spec/support/shared_examples_for_request.rb +0 -94
- data/spec/support/spec_support.rb +0 -20
- data/spec/support/stubbing.json +0 -22
- data/spec/support/stubbing_using_allow.rb +0 -29
- data/spec/support/term.json +0 -48
- data/spec/support/test_app_fail.json +0 -61
- data/spec/support/test_app_pass.json +0 -38
- data/spec/support/test_app_with_right_content_type_differ.json +0 -23
- data/tasks/pact-test.rake +0 -109
- data/tasks/spec.rake +0 -8
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@ Do this to generate your change history
|
|
|
2
2
|
|
|
3
3
|
git log --pretty=format:' * %h - %s (%an, %ad)'
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### 1.4.0 (25 November 2014)
|
|
8
|
+
|
|
9
|
+
* e596eb8 - Added appraisal gem so we can test against RSpec 2 and 3. (bethesque, Thu Nov 20 09:31:13 2014 +1100)
|
|
10
|
+
* fb40662 - Rescue EOFError when starting server jruby fails because of this all the time on TravisCI (bethesque, Fri Nov 14 15:58:08 2014 +1100)
|
|
11
|
+
* c1e8b55 - Removing extraneous files from being included in the gem (bethesque, Fri Nov 14 14:03:44 2014 +1100)
|
|
12
|
+
* 247e1c2 - Added example pact:publish task to example app (bethesque, Tue Nov 11 21:30:48 2014 +1100)
|
|
13
|
+
* 935b318 - Removed Gemfile.lock from source control (bethesque, Fri Oct 24 16:02:36 2014 +1100)
|
|
14
|
+
* b2f9073 - Mock Service client must now specify the pact dir (bethesque, Fri Oct 24 09:39:12 2014 +1100)
|
|
15
|
+
* c64e122 - Add the ability to use regex in headers when defining the response. (Michael Treacher, Thu Oct 23 21:22:13 2014 +1100)
|
|
16
|
+
* 892e526 - Removed jruby-19mode from .travis.yml, it fails inconsistently with EOF error. (bethesque, Wed Oct 22 16:26:28 2014 +1100)
|
|
17
|
+
|
|
18
|
+
### 1.4.0.rc4 (22 October 2014)
|
|
19
|
+
|
|
20
|
+
* e56775a - Upgraded pact support gems to allow form bodies to be specified as Hashes with Pact::Terms (bethesque, Wed Oct 22 15:31:30 2014 +1100)
|
|
21
|
+
|
|
22
|
+
### 1.4.0.rc3 (17 October 2014)
|
|
23
|
+
|
|
24
|
+
* 602906f - Upped pact-support version to allow queries specified as hashes. (bethesque, Fri Oct 17 14:30:39 2014 +1100)
|
|
25
|
+
|
|
26
|
+
### 1.4.0.rc2 (12 October 2014)
|
|
27
|
+
|
|
28
|
+
* 61036fc - Updating pact-support version (bethesque, Sun Oct 12 14:39:36 2014 +1100)
|
|
29
|
+
|
|
30
|
+
### 1.4.0.rc1 (12 October 2014)
|
|
31
|
+
|
|
32
|
+
* df3342f - Removing pact server command as it is now in pact-mock_service (bethesque, Sun Oct 12 12:39:56 2014 +1100)
|
|
33
|
+
* 12ccdb7 - Making gem source configurable (bethesque, Sun Oct 12 12:39:32 2014 +1100)
|
|
34
|
+
* 5b76516 - Removed files that are now in pact-support (bethesque, Sun Oct 12 11:40:57 2014 +1100)
|
|
35
|
+
* c4365c5 - Fix bug in calling of SomethingLike serialisation (André Allavena, Fri Oct 10 15:39:57 2014 +1000)
|
|
36
|
+
* 546b5c7 - JSON isn't auto-loaded; require it before use. (Daniel Heath, Wed Oct 8 13:31:24 2014 +1100)
|
|
37
|
+
* 7cac7e9 - Replaced response hash with Response class - say no to Hash Driven Development (bethesque, Fri Oct 3 17:22:38 2014 +1000)
|
|
38
|
+
* 36940d3 - Added test cases to show response headers are case insensitive (bethesque, Fri Oct 3 15:25:03 2014 +1000)
|
|
39
|
+
* f4422e2 - Fix typos in README (Mark Dalgleish, Mon Sep 29 17:12:17 2014 +1000)
|
|
40
|
+
|
|
5
41
|
### 1.3.3 (23 September 2014)
|
|
6
42
|
|
|
7
43
|
* 9106aac - Fixed reification when using FactoryGirl. (bethesque, Tue Sep 23 08:23:51 2014 +1000)
|
|
@@ -35,7 +71,7 @@ Do this to generate your change history
|
|
|
35
71
|
|
|
36
72
|
### 1.2.1.rc2 (13 June 2014)
|
|
37
73
|
|
|
38
|
-
* d805f35 - Ensuring the pact RSpec formatter works for both rspec 2 and rspec 3 (
|
|
74
|
+
* d805f35 - Ensuring the pact RSpec formatter works for both rspec 2 and rspec 3 (bethesque, Fri Jun 13 16:27:01 2014 +1000)
|
|
39
75
|
* 1669d46 - Fix require for sample app to work without munging LOAD_PATH (Daniel Heath, Fri Jun 13 15:50:03 2014 +1000)
|
|
40
76
|
|
|
41
77
|
### 1.2.1.rc1 (13 June 2014)
|
data/lib/pact/cli.rb
CHANGED
|
@@ -15,15 +15,6 @@ module Pact
|
|
|
15
15
|
RunPactVerification.call(options)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
desc 'service', "Start a mock service"
|
|
19
|
-
method_option :port, aliases: "-p", desc: "Port on which to run the service"
|
|
20
|
-
method_option :log, aliases: "-l", desc: "File to which to log output"
|
|
21
|
-
method_option :quiet, aliases: "-q", desc: "If true, no admin messages will be shown"
|
|
22
|
-
|
|
23
|
-
def service
|
|
24
|
-
RunStandaloneMockService.call(options)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
18
|
private
|
|
28
19
|
|
|
29
20
|
def log message
|
|
@@ -98,23 +89,6 @@ module Pact
|
|
|
98
89
|
|
|
99
90
|
end
|
|
100
91
|
|
|
101
|
-
class RunStandaloneMockService
|
|
102
|
-
|
|
103
|
-
def self.call options
|
|
104
|
-
service_options = {}
|
|
105
|
-
if options[:log]
|
|
106
|
-
log = File.open(options[:log], 'w')
|
|
107
|
-
log.sync = true
|
|
108
|
-
service_options[:log_file] = log
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
port = options[:port] || FindAPort.available_port
|
|
112
|
-
mock_service = Consumer::MockService.new(service_options)
|
|
113
|
-
trap(:INT) { Rack::Handler::WEBrick.shutdown }
|
|
114
|
-
Rack::Handler::WEBrick.run(mock_service, :Port => port, :AccessLog => [])
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
92
|
class SpecCriteria
|
|
119
93
|
|
|
120
94
|
def self.call
|
|
@@ -1,14 +1,65 @@
|
|
|
1
|
+
require 'pact/configuration'
|
|
2
|
+
require 'pact/doc/markdown/generator'
|
|
3
|
+
|
|
1
4
|
module Pact
|
|
2
5
|
module Consumer
|
|
3
6
|
module Configuration
|
|
4
7
|
|
|
5
8
|
module ConfigurationExtensions
|
|
9
|
+
|
|
10
|
+
DOC_GENERATORS = { markdown: Pact::Doc::Markdown::Generator }
|
|
11
|
+
|
|
12
|
+
def doc_dir
|
|
13
|
+
@doc_dir ||= File.expand_path("./doc/pacts")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def doc_dir= doc_dir
|
|
17
|
+
@doc_dir = doc_dir
|
|
18
|
+
end
|
|
19
|
+
|
|
6
20
|
def add_provider_verification &block
|
|
7
21
|
provider_verifications << block
|
|
8
22
|
end
|
|
23
|
+
|
|
9
24
|
def provider_verifications
|
|
10
25
|
@provider_verifications ||= []
|
|
11
26
|
end
|
|
27
|
+
|
|
28
|
+
def doc_generator= doc_generator
|
|
29
|
+
doc_generators << begin
|
|
30
|
+
if DOC_GENERATORS[doc_generator]
|
|
31
|
+
DOC_GENERATORS[doc_generator]
|
|
32
|
+
elsif doc_generator.respond_to?(:call)
|
|
33
|
+
doc_generator
|
|
34
|
+
else
|
|
35
|
+
raise "Pact.configuration.doc_generator needs to respond to call, or be in the preconfigured list: #{DOC_GENERATORS.keys}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def doc_generators
|
|
41
|
+
@doc_generators ||= []
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def pactfile_write_mode
|
|
45
|
+
@pactfile_write_mode ||= :overwrite
|
|
46
|
+
if @pactfile_write_mode == :smart
|
|
47
|
+
is_rake_running? ? :overwrite : :update
|
|
48
|
+
else
|
|
49
|
+
@pactfile_write_mode
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def pactfile_write_mode= pactfile_write_mode
|
|
54
|
+
@pactfile_write_mode = pactfile_write_mode
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
#Would love a better way of determining this! It sure won't work on windows.
|
|
60
|
+
def is_rake_running?
|
|
61
|
+
`ps -ef | grep rake | grep #{Process.ppid} | grep -v 'grep'`.size > 0
|
|
62
|
+
end
|
|
12
63
|
end
|
|
13
64
|
end
|
|
14
65
|
end
|
|
@@ -61,7 +61,8 @@ module Pact
|
|
|
61
61
|
:consumer_name => consumer_name,
|
|
62
62
|
:provider_name => provider_name,
|
|
63
63
|
:pactfile_write_mode => Pact.configuration.pactfile_write_mode,
|
|
64
|
-
:port => port
|
|
64
|
+
:port => port,
|
|
65
|
+
:pact_dir => Pact.configuration.pact_dir
|
|
65
66
|
}
|
|
66
67
|
Pact::Consumer::ConsumerContractBuilder.new consumer_contract_builder_fields
|
|
67
68
|
end
|
|
@@ -6,6 +6,5 @@ require 'pact/consumer/configuration/service_provider'
|
|
|
6
6
|
require 'pact/consumer/configuration/dsl'
|
|
7
7
|
require 'pact/consumer/configuration/configuration_extensions'
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
Pact.send(:extend, Pact::Consumer::DSL)
|
|
11
10
|
Pact::Configuration.send(:include, Pact::Consumer::Configuration::ConfigurationExtensions)
|
|
@@ -18,7 +18,8 @@ module Pact
|
|
|
18
18
|
@consumer_contract_details = {
|
|
19
19
|
consumer: {name: attributes[:consumer_name]},
|
|
20
20
|
provider: {name: attributes[:provider_name]},
|
|
21
|
-
pactfile_write_mode: attributes[:pactfile_write_mode].to_s
|
|
21
|
+
pactfile_write_mode: attributes[:pactfile_write_mode].to_s,
|
|
22
|
+
pact_dir: attributes.fetch(:pact_dir)
|
|
22
23
|
}
|
|
23
24
|
@mock_service_client = MockServiceClient.new(attributes[:port])
|
|
24
25
|
@mock_service_base_url = "http://localhost:#{attributes[:port]}"
|
|
@@ -35,8 +36,7 @@ module Pact
|
|
|
35
36
|
def interaction_builder
|
|
36
37
|
@interaction_builder ||=
|
|
37
38
|
begin
|
|
38
|
-
interaction_builder = InteractionBuilder.new
|
|
39
|
-
interaction_builder.on_interaction_fully_defined do | interaction |
|
|
39
|
+
interaction_builder = InteractionBuilder.new do | interaction |
|
|
40
40
|
self.handle_interaction_fully_defined(interaction)
|
|
41
41
|
end
|
|
42
42
|
interaction_builder
|
|
@@ -8,8 +8,9 @@ module Pact
|
|
|
8
8
|
|
|
9
9
|
attr_reader :interaction
|
|
10
10
|
|
|
11
|
-
def initialize
|
|
11
|
+
def initialize &block
|
|
12
12
|
@interaction = Interaction.new
|
|
13
|
+
@callback = block
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def upon_receiving description
|
|
@@ -28,14 +29,11 @@ module Pact
|
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
def will_respond_with(response)
|
|
31
|
-
interaction.response = response
|
|
32
|
+
interaction.response = Pact::Response.new(response)
|
|
32
33
|
@callback.call interaction
|
|
33
34
|
self
|
|
34
35
|
end
|
|
35
36
|
|
|
36
|
-
def on_interaction_fully_defined &block
|
|
37
|
-
@callback = block
|
|
38
|
-
end
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
end
|
|
@@ -31,7 +31,7 @@ module Pact
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def response_status
|
|
34
|
-
interaction.response
|
|
34
|
+
interaction.response.status
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def consumer_name
|
|
@@ -67,7 +67,10 @@ module Pact
|
|
|
67
67
|
attr_reader :interaction, :consumer_contract
|
|
68
68
|
|
|
69
69
|
def clean_request
|
|
70
|
-
|
|
70
|
+
reified_request = Reification.from_term(interaction.request)
|
|
71
|
+
ordered_clean_hash(reified_request).tap do | hash |
|
|
72
|
+
hash[:body] = reified_request[:body] if reified_request[:body]
|
|
73
|
+
end
|
|
71
74
|
end
|
|
72
75
|
|
|
73
76
|
def clean_response
|
|
@@ -80,17 +83,17 @@ module Pact
|
|
|
80
83
|
def ordered_clean_hash source
|
|
81
84
|
ordered_keys.each_with_object({}) do |key, target|
|
|
82
85
|
if source.key? key
|
|
83
|
-
target[key] = source[key] unless
|
|
86
|
+
target[key] = source[key] unless value_is_an_empty_hash(source[key])
|
|
84
87
|
end
|
|
85
88
|
end
|
|
86
89
|
end
|
|
87
90
|
|
|
88
|
-
def
|
|
89
|
-
value.is_a?(Hash) && value.empty?
|
|
91
|
+
def value_is_an_empty_hash value
|
|
92
|
+
value.is_a?(Hash) && value.empty?
|
|
90
93
|
end
|
|
91
94
|
|
|
92
95
|
def ordered_keys
|
|
93
|
-
[:method, :path, :query, :
|
|
96
|
+
[:method, :path, :query, :status, :headers, :body]
|
|
94
97
|
end
|
|
95
98
|
|
|
96
99
|
def remove_key_if_empty key, hash
|
|
@@ -9,7 +9,7 @@ module Pact
|
|
|
9
9
|
private
|
|
10
10
|
|
|
11
11
|
def self.sortable_id interaction
|
|
12
|
-
"#{interaction.description.downcase} #{interaction.response
|
|
12
|
+
"#{interaction.description.downcase} #{interaction.response.status} #{(interaction.provider_state || '').downcase}"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
end
|
|
@@ -37,15 +37,6 @@ module Pact
|
|
|
37
37
|
@config_ru_path = config_ru_path
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def color_enabled
|
|
41
|
-
# Can't use ||= when the variable might be false, it will execute the expression if it's false
|
|
42
|
-
defined?(@color_enabled) ? @color_enabled : true
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def color_enabled= color_enabled
|
|
46
|
-
@color_enabled = color_enabled
|
|
47
|
-
end
|
|
48
|
-
|
|
49
40
|
def include mod
|
|
50
41
|
Pact::Provider::State::ProviderStateConfiguredModules.instance_eval do
|
|
51
42
|
include mod
|
data/lib/pact/provider/rspec.rb
CHANGED
|
@@ -68,8 +68,10 @@ module Pact
|
|
|
68
68
|
|
|
69
69
|
describe description_for(interaction), metadata do
|
|
70
70
|
|
|
71
|
+
|
|
71
72
|
describe "with #{interaction.request.method_and_path}" do
|
|
72
73
|
|
|
74
|
+
|
|
73
75
|
interaction_context = InteractionContext.new
|
|
74
76
|
|
|
75
77
|
before do | example |
|
|
@@ -87,7 +89,7 @@ module Pact
|
|
|
87
89
|
end
|
|
88
90
|
end
|
|
89
91
|
|
|
90
|
-
describe_response Pact::Term.unpack_regexps(interaction.response), interaction_context
|
|
92
|
+
describe_response Pact::Response.new(Pact::Term.unpack_regexps(interaction.response)), interaction_context
|
|
91
93
|
|
|
92
94
|
end
|
|
93
95
|
|
|
@@ -101,27 +103,27 @@ module Pact
|
|
|
101
103
|
|
|
102
104
|
include Pact::RSpec::Matchers
|
|
103
105
|
|
|
104
|
-
let(:expected_response_status) { expected_response
|
|
105
|
-
let(:expected_response_body) { expected_response
|
|
106
|
+
let(:expected_response_status) { expected_response.status }
|
|
107
|
+
let(:expected_response_body) { expected_response.body }
|
|
106
108
|
let(:response) { interaction_context.last_response }
|
|
107
109
|
let(:response_status) { response.status }
|
|
108
110
|
let(:response_body) { parse_body_from_response(response) }
|
|
109
111
|
let(:differ) { Pact.configuration.body_differ_for_content_type diff_content_type }
|
|
110
112
|
let(:diff_formatter) { Pact.configuration.diff_formatter_for_content_type diff_content_type }
|
|
111
|
-
let(:expected_content_type) { Pact::Headers.new(expected_response
|
|
113
|
+
let(:expected_content_type) { Pact::Headers.new(expected_response.headers || {})['Content-Type'] }
|
|
112
114
|
let(:actual_content_type) { response.headers['Content-Type']}
|
|
113
115
|
let(:diff_content_type) { String === expected_content_type ? expected_content_type : actual_content_type } # expected_content_type may be a Regexp
|
|
114
116
|
let(:diff_options) { { with: differ, diff_formatter: diff_formatter } }
|
|
115
117
|
|
|
116
|
-
if expected_response
|
|
117
|
-
it "has status code #{expected_response
|
|
118
|
+
if expected_response.status
|
|
119
|
+
it "has status code #{expected_response.status}" do
|
|
118
120
|
expect(response_status).to eql expected_response_status
|
|
119
121
|
end
|
|
120
122
|
end
|
|
121
123
|
|
|
122
|
-
if expected_response
|
|
124
|
+
if expected_response.headers
|
|
123
125
|
describe "includes headers" do
|
|
124
|
-
expected_response
|
|
126
|
+
expected_response.headers.each do |name, expected_header_value|
|
|
125
127
|
it "\"#{name}\" with value #{expected_header_value.inspect}" do
|
|
126
128
|
header_value = response.headers[name]
|
|
127
129
|
expect(header_value).to match_header(name, expected_header_value)
|
|
@@ -130,7 +132,7 @@ module Pact
|
|
|
130
132
|
end
|
|
131
133
|
end
|
|
132
134
|
|
|
133
|
-
if expected_response
|
|
135
|
+
if expected_response.body
|
|
134
136
|
it "has a matching body" do
|
|
135
137
|
expect(response_body).to match_term expected_response_body, diff_options
|
|
136
138
|
end
|
data/lib/pact/version.rb
CHANGED
data/lib/pact.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
require 'pact/support'
|
|
2
|
+
require 'pact/version'
|
|
3
|
+
require 'pact/configuration'
|
|
4
|
+
require 'pact/consumer'
|
|
5
|
+
require 'pact/provider'
|
|
6
|
+
require 'pact/consumer_contract'
|
data/pact.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
|
12
12
|
gem.summary = %q{Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.}
|
|
13
13
|
gem.homepage = "https://github.com/realestate-com-au/pact"
|
|
14
14
|
|
|
15
|
-
gem.files = `git ls-files`.split($/)
|
|
15
|
+
gem.files = `git ls-files bin lib pact.gemspec CHANGELOG.md LICENSE.txt`.split($/)
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
gem.require_paths = ["lib"]
|
|
@@ -28,11 +28,15 @@ 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', '~> 0.1.2'
|
|
32
|
+
gem.add_runtime_dependency 'pact-mock_service', '~> 0.2.0'
|
|
33
|
+
|
|
31
34
|
gem.add_development_dependency 'rake', '~> 10.0.3'
|
|
32
35
|
gem.add_development_dependency 'webmock', '~> 1.18.0'
|
|
33
36
|
gem.add_development_dependency 'pry'
|
|
34
|
-
gem.add_development_dependency 'fakefs', '
|
|
37
|
+
gem.add_development_dependency 'fakefs', '0.5' # 0.6.0 blows up
|
|
35
38
|
gem.add_development_dependency 'hashie', '~> 2.0'
|
|
36
39
|
gem.add_development_dependency 'activesupport'
|
|
37
40
|
gem.add_development_dependency 'faraday'
|
|
41
|
+
gem.add_development_dependency 'appraisal'
|
|
38
42
|
end
|