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
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/matchers/unix_diff_formatter'
|
|
3
|
-
require 'pact/matchers/expected_type'
|
|
4
|
-
require 'pact/matchers/actual_type'
|
|
5
|
-
|
|
6
|
-
module Pact
|
|
7
|
-
module Matchers
|
|
8
|
-
describe UnixDiffFormatter do
|
|
9
|
-
|
|
10
|
-
describe ".call" do
|
|
11
|
-
|
|
12
|
-
let(:key_lines_count) { 4 }
|
|
13
|
-
let(:colour) { false }
|
|
14
|
-
subject { UnixDiffFormatter.call(diff, {colour: colour}) }
|
|
15
|
-
|
|
16
|
-
let(:line_count) { subject.split("\n").size }
|
|
17
|
-
|
|
18
|
-
context "when colour = false" do
|
|
19
|
-
let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, "Joe" )}} }
|
|
20
|
-
it "does not include colour" do
|
|
21
|
-
expect(subject).to_not include("[0m")
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context "when colour = true" do
|
|
26
|
-
let(:colour) { true }
|
|
27
|
-
let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, "Joe" )}} }
|
|
28
|
-
it "uses colour" do
|
|
29
|
-
expect(subject).to include("[0m")
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "with class based matching" do
|
|
34
|
-
let(:diff) { {thing: TypeDifference.new(ExpectedType.new("fred"), ActualType.new(1))}}
|
|
35
|
-
let(:output) { <<-EOF
|
|
36
|
-
{
|
|
37
|
-
- "thing": String
|
|
38
|
-
+ "thing": Fixnum
|
|
39
|
-
}
|
|
40
|
-
EOF
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
it "displays nicely" do
|
|
44
|
-
expect(remove_ansicolor subject).to include output
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context "with an incorrect value in a hash" do
|
|
49
|
-
let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, "Joe" )}} }
|
|
50
|
-
|
|
51
|
-
it "displays '+' next to the unexpected value, and '-' next to the missing one" do
|
|
52
|
-
expect(subject).to match /alligator/
|
|
53
|
-
expect(subject).to match /\-.*Mary/
|
|
54
|
-
expect(subject).to match /\+.*Joe/
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
58
|
-
expect(line_count).to eq 9 + key_lines_count
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context "with an incorrect value in an array" do
|
|
64
|
-
let(:diff) { [NoDiffIndicator.new, Difference.new({name: 'Mary'}, "Joe"), NoDiffIndicator.new] }
|
|
65
|
-
|
|
66
|
-
it "displays '+' next to the incorrect values and '-' next to the missing ones" do
|
|
67
|
-
expect(subject).to match /no difference here!/
|
|
68
|
-
expect(subject).to match /\-.*{/
|
|
69
|
-
expect(subject).to match /\-.*}/
|
|
70
|
-
expect(subject).to match /\-.*Mary/
|
|
71
|
-
expect(subject).to match /\+.*Joe/
|
|
72
|
-
expect(subject).to match /no.*Mary.*Joe.*no/m
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "doesn't display the no difference indicator as a change" do
|
|
76
|
-
expect(subject).to match(/^\s+no difference here!,$/)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
80
|
-
expect(line_count).to eq 9 + key_lines_count
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "with a regular expression that was not matched" do
|
|
86
|
-
let(:regexp) { %r{http://.*/thing/1234} }
|
|
87
|
-
let(:diff) { {thing: RegexpDifference.new(regexp, "pear")} }
|
|
88
|
-
|
|
89
|
-
it "displays the regular expression" do
|
|
90
|
-
expect(subject).to include(regexp.inspect)
|
|
91
|
-
expect(subject).to include(regexp.inspect)
|
|
92
|
-
expect(subject).to match /\-.*thing/
|
|
93
|
-
expect(subject).to match /\+.*pear/
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "does not put quotes around the regular expression" do
|
|
97
|
-
expect(subject).to match /\/$/
|
|
98
|
-
expect(subject).to match /: \//
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
102
|
-
expect(line_count).to eq 5 + key_lines_count
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
context "with a missing key" do
|
|
108
|
-
|
|
109
|
-
let(:diff) { {thing: {alligator: Difference.new({name: 'Mary'}, KeyNotFound.new )}} }
|
|
110
|
-
|
|
111
|
-
it "it displays '-' next to the missing key and its value" do
|
|
112
|
-
expect(subject).to match /\-.*{/
|
|
113
|
-
expect(subject).to match /\-.*}/
|
|
114
|
-
expect(subject).to match /\-.*alligator/
|
|
115
|
-
expect(subject).to match /\-.*name/
|
|
116
|
-
expect(subject).to match /\-.*Mary/
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "does not display the missing key in the actual output" do
|
|
120
|
-
expect(subject).to_not match /\+.*alligator/
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
124
|
-
expect(line_count).to eq 8 + key_lines_count
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context "with an unexpected key" do
|
|
129
|
-
let(:diff) { {thing: {alligator: Difference.new(UnexpectedKey.new, {name: 'Mary'} )}} }
|
|
130
|
-
|
|
131
|
-
it "displays '+' next to the unexpected key and its value" do
|
|
132
|
-
expect(subject).to match /\+.*name/
|
|
133
|
-
expect(subject).to match /\+.*Mary/
|
|
134
|
-
expect(subject).to match /\+.*alligator/
|
|
135
|
-
expect(subject).to match /\+.*}/
|
|
136
|
-
expect(subject).to match /\+.*{/
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it "does not display the unexpected key in the expected output" do
|
|
140
|
-
expect(subject).to_not match /\-.*alligator/
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
144
|
-
expect(line_count).to eq 8 + key_lines_count
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
context "with a missing index" do
|
|
150
|
-
let(:diff) { [NoDiffIndicator.new, Difference.new({name: 'Mary'}, IndexNotFound.new)] }
|
|
151
|
-
|
|
152
|
-
it "displays '-' next to the missing items" do
|
|
153
|
-
expect(subject).to match /\-.*Mary/
|
|
154
|
-
expect(subject).to match /\-.*{/
|
|
155
|
-
expect(subject).to match /\-.*}/
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "does not display IndexNotFound" do
|
|
159
|
-
expect(subject).to_not match /#{IndexNotFound.new.to_s}/
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
163
|
-
expect(line_count).to eq 8 + key_lines_count
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
context "with an unexpected index" do
|
|
169
|
-
let(:diff) { [NoDiffIndicator.new, Difference.new(UnexpectedIndex.new, {name: 'Mary'})] }
|
|
170
|
-
|
|
171
|
-
it "displays '+' next to the unexpected item" do
|
|
172
|
-
expect(subject).to match /\+.*{/
|
|
173
|
-
expect(subject).to match /\+.*}/
|
|
174
|
-
expect(subject).to match /\+.*name/
|
|
175
|
-
expect(subject).to match /\+.*Mary/
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
xit "doesn't mark the 'no difference' as a change" do
|
|
179
|
-
expect(subject).to match /#{NoDiffIndicator.new.to_s},/
|
|
180
|
-
expect(subject).to_not match /\-.*#{NoDiffIndicator.new.to_s}/
|
|
181
|
-
expect(subject).to_not match /\+.*#{NoDiffIndicator.new.to_s}/
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
it "does not display the UnexpectedIndex" do
|
|
185
|
-
expect(subject).to_not match UnexpectedIndex.new.to_s
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
189
|
-
expect(line_count).to eq 8 + key_lines_count
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
context "with 2 unexpected indexes" do
|
|
195
|
-
let(:diff) { [NoDiffIndicator.new, Difference.new(UnexpectedIndex.new, {name: 'Mary'}), Difference.new(UnexpectedIndex.new, {name: 'Joe'})] }
|
|
196
|
-
|
|
197
|
-
it "displays '+' next to the unexpected item" do
|
|
198
|
-
expect(subject).to match /\+.*Mary/
|
|
199
|
-
expect(subject).to match /\+.*Joe/
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
it "does not display the UnexpectedIndex" do
|
|
203
|
-
expect(subject).to_not match UnexpectedIndex.new.to_s
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it "generates the right number of lines, even with ActiveSupport loaded" do
|
|
207
|
-
expect(line_count).to eq 11 + key_lines_count
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/configuration/configuration_extension'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
|
|
6
|
-
module Provider
|
|
7
|
-
|
|
8
|
-
module Configuration
|
|
9
|
-
|
|
10
|
-
describe ConfigurationExtension do
|
|
11
|
-
|
|
12
|
-
subject { Object.new.extend(ConfigurationExtension) }
|
|
13
|
-
|
|
14
|
-
describe "#color_enabled" do
|
|
15
|
-
|
|
16
|
-
it "sets color_enabled to be true by default" do
|
|
17
|
-
expect(subject.color_enabled).to be true
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "allows configuration of colour_enabled" do
|
|
21
|
-
subject.color_enabled = false
|
|
22
|
-
expect(subject.color_enabled).to be false
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/configuration/pact_verification'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
module Provider
|
|
6
|
-
module Configuration
|
|
7
|
-
describe PactVerification do
|
|
8
|
-
|
|
9
|
-
describe 'create_verification' do
|
|
10
|
-
let(:url) {'http://some/uri'}
|
|
11
|
-
let(:consumer_name) {'some consumer'}
|
|
12
|
-
let(:ref) {:prod}
|
|
13
|
-
let(:options) { {:ref => :prod} }
|
|
14
|
-
context "with valid values" do
|
|
15
|
-
subject do
|
|
16
|
-
uri = url
|
|
17
|
-
PactVerification.build(consumer_name, options) do
|
|
18
|
-
pact_uri uri
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "creates a Verification" do
|
|
23
|
-
expect(Pact::Provider::PactVerification).to receive(:new).with(consumer_name, url, ref)
|
|
24
|
-
subject
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context "with a nil uri" do
|
|
29
|
-
subject do
|
|
30
|
-
PactVerification.build(consumer_name, options) do
|
|
31
|
-
pact_uri nil
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "raises a validation error" do
|
|
36
|
-
expect{ subject }.to raise_error /Please provide a pact_uri/
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/configuration/service_provider_config'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
module Provider
|
|
6
|
-
module Configuration
|
|
7
|
-
describe ServiceProviderConfig do
|
|
8
|
-
|
|
9
|
-
describe "app" do
|
|
10
|
-
|
|
11
|
-
subject { ServiceProviderConfig.new { Object.new } }
|
|
12
|
-
|
|
13
|
-
it "should execute the app_block each time" do
|
|
14
|
-
expect(subject.app.object_id).to_not equal(subject.app.object_id)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/configuration/service_provider_dsl'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
|
|
6
|
-
module Provider
|
|
7
|
-
|
|
8
|
-
module Configuration
|
|
9
|
-
|
|
10
|
-
describe ServiceProviderDSL do
|
|
11
|
-
|
|
12
|
-
describe "initialize" do
|
|
13
|
-
|
|
14
|
-
context "with an object instead of a block" do
|
|
15
|
-
subject do
|
|
16
|
-
ServiceProviderDSL.build 'name' do
|
|
17
|
-
app 'blah'
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
it "raises an error" do
|
|
21
|
-
expect{ subject }.to raise_error /wrong number of arguments/
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe "validate" do
|
|
28
|
-
context "when no name is provided" do
|
|
29
|
-
subject do
|
|
30
|
-
ServiceProviderDSL.new ' ' do
|
|
31
|
-
app { Object.new }
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
it "raises an error" do
|
|
35
|
-
expect{ subject.send(:validate)}.to raise_error("Please provide a name for the Provider")
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
context "when nil name is provided" do
|
|
39
|
-
subject do
|
|
40
|
-
ServiceProviderDSL.new nil do
|
|
41
|
-
app { Object.new }
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
it "raises an error" do
|
|
45
|
-
expect{ subject.send(:validate)}.to raise_error("Please provide a name for the Provider")
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe 'honours_pact_with' do
|
|
51
|
-
before do
|
|
52
|
-
Pact.clear_configuration
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
context "with no optional params" do
|
|
56
|
-
subject do
|
|
57
|
-
ServiceProviderDSL.build 'some-provider' do
|
|
58
|
-
app {}
|
|
59
|
-
honours_pact_with 'some-consumer' do
|
|
60
|
-
pact_uri 'blah'
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
it 'adds a verification to the Pact.configuration' do
|
|
65
|
-
subject
|
|
66
|
-
expect(Pact.configuration.pact_verifications.first).to eq(Pact::Provider::PactVerification.new('some-consumer', 'blah', :head))
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context "with all params specified" do
|
|
71
|
-
subject do
|
|
72
|
-
ServiceProviderDSL.build 'some-provider' do
|
|
73
|
-
app {}
|
|
74
|
-
honours_pact_with 'some-consumer', :ref => :prod do
|
|
75
|
-
pact_uri 'blah'
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
it 'adds a verification to the Pact.configuration' do
|
|
80
|
-
subject
|
|
81
|
-
expect(Pact.configuration.pact_verifications.first).to eq(Pact::Provider::PactVerification.new('some-consumer', 'blah', :prod))
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe "CONFIG_RU_APP" do
|
|
89
|
-
context "when a config.ru file does not exist" do
|
|
90
|
-
|
|
91
|
-
let(:path_that_does_not_exist) { './tmp/this/path/does/not/exist/probably' }
|
|
92
|
-
|
|
93
|
-
before do
|
|
94
|
-
allow(Pact.configuration).to receive(:config_ru_path).and_return(path_that_does_not_exist)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "raises an error with some helpful text" do
|
|
98
|
-
expect{ ServiceProviderDSL::CONFIG_RU_APP.call }.to raise_error /Could not find config\.ru file.*#{Regexp.escape(path_that_does_not_exist)}/
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/configuration'
|
|
3
|
-
|
|
4
|
-
module Pact::Provider::Configuration
|
|
5
|
-
|
|
6
|
-
describe ConfigurationExtension do
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
Pact.clear_configuration
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "service_provider" do
|
|
13
|
-
|
|
14
|
-
context "when a provider is configured" do
|
|
15
|
-
|
|
16
|
-
before do
|
|
17
|
-
Pact.service_provider "Fred" do
|
|
18
|
-
app { "An app" }
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should allow configuration of the test app" do
|
|
23
|
-
expect(Pact.configuration.provider.app).to eql "An app"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context "when a provider is not configured" do
|
|
29
|
-
|
|
30
|
-
it "raises an error" do
|
|
31
|
-
expect{ Pact.configuration.provider }.to raise_error(/Please configure your provider/)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context "when a provider is configured without an app" do
|
|
37
|
-
|
|
38
|
-
before do
|
|
39
|
-
Pact.service_provider "Fred" do
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "uses the app from config.ru" do
|
|
44
|
-
expect( Pact.configuration.provider.app ).to be(AppForConfigRu)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/matchers/messages'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
module Matchers
|
|
6
|
-
describe Messages do
|
|
7
|
-
|
|
8
|
-
include Messages
|
|
9
|
-
|
|
10
|
-
describe "#match_term_failure_message" do
|
|
11
|
-
|
|
12
|
-
let(:diff_formatter) { Pact::Matchers::UnixDiffFormatter }
|
|
13
|
-
let(:message) { "line1\nline2"}
|
|
14
|
-
let(:output_message) { "Actual: actual\n\n#{message}"}
|
|
15
|
-
let(:output_message_with_resets) { "Actual: actual\n\n#{r}line1\n#{r}line2"}
|
|
16
|
-
let(:r) { ::Term::ANSIColor.reset }
|
|
17
|
-
let(:diff) { double("diff") }
|
|
18
|
-
let(:actual) { "actual" }
|
|
19
|
-
let(:color_enabled) { true }
|
|
20
|
-
let(:ansi_reset_at_start_of_line) { /^#{Regexp.escape ::Term::ANSIColor.reset}/ }
|
|
21
|
-
let(:message_line_count) { message.split("\n").size }
|
|
22
|
-
|
|
23
|
-
before do
|
|
24
|
-
allow(diff_formatter).to receive(:call).and_return(message)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
subject { match_term_failure_message diff, actual, diff_formatter, color_enabled }
|
|
28
|
-
|
|
29
|
-
it "creates a message using the diff_formatter" do
|
|
30
|
-
expect(diff_formatter).to receive(:call).with(diff)
|
|
31
|
-
subject
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context "when color_enabled is true" do
|
|
35
|
-
|
|
36
|
-
it "returns the message with ANSI reset at the start of each line" do
|
|
37
|
-
expect(subject).to eq(output_message_with_resets)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context "when the actual is not a string" do
|
|
43
|
-
|
|
44
|
-
let(:actual) { {the: "actual"} }
|
|
45
|
-
|
|
46
|
-
it "includes the actual as json" do
|
|
47
|
-
expect(subject).to include(actual.to_json)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context "when color_enabled is false" do
|
|
52
|
-
|
|
53
|
-
let(:color_enabled) { false }
|
|
54
|
-
|
|
55
|
-
it "returns the message unmodified" do
|
|
56
|
-
expect(subject).to eq(output_message)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe "#match_header_failure_message" do
|
|
64
|
-
|
|
65
|
-
let(:header_name) { "Content-Type" }
|
|
66
|
-
let(:expected) { "application/json" }
|
|
67
|
-
let(:actual) { "text/plain" }
|
|
68
|
-
|
|
69
|
-
subject { match_header_failure_message header_name, expected, actual }
|
|
70
|
-
|
|
71
|
-
context "when the expected value is a string" do
|
|
72
|
-
|
|
73
|
-
let(:expected_message) { "Expected header \"Content-Type\" to match \"application/json\", but was \"text/plain\"" }
|
|
74
|
-
|
|
75
|
-
it "creates a message" do
|
|
76
|
-
expect(subject).to eq(expected_message)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context "when the actual is nil" do
|
|
82
|
-
|
|
83
|
-
let(:actual) { nil }
|
|
84
|
-
let(:expected_message) { "Expected header \"Content-Type\" to match \"application/json\", but was nil" }
|
|
85
|
-
|
|
86
|
-
it "creates a message" do
|
|
87
|
-
expect(subject).to eq(expected_message)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
context "when the expected is nil" do
|
|
93
|
-
|
|
94
|
-
let(:expected) { nil }
|
|
95
|
-
let(:expected_message) { "Expected header \"Content-Type\" to be nil, but was \"text/plain\"" }
|
|
96
|
-
|
|
97
|
-
it "creates a message" do
|
|
98
|
-
expect(subject).to eq(expected_message)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
context "when the expected is a regexp" do
|
|
104
|
-
|
|
105
|
-
let(:expected) { /hal/ }
|
|
106
|
-
let(:expected_message) { "Expected header \"Content-Type\" to match /hal/, but was \"text/plain\"" }
|
|
107
|
-
|
|
108
|
-
it "creates a message with the term's matcher" do
|
|
109
|
-
expect(subject).to eq(expected_message)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/pact_helper_locator'
|
|
3
|
-
|
|
4
|
-
module Pact::Provider
|
|
5
|
-
|
|
6
|
-
describe PactHelperLocater do
|
|
7
|
-
describe "pact_helper_path", :fakefs => true do
|
|
8
|
-
|
|
9
|
-
subject { PactHelperLocater.pact_helper_path }
|
|
10
|
-
|
|
11
|
-
def make_pactfile dir
|
|
12
|
-
FileUtils.mkdir_p ".#{dir}"
|
|
13
|
-
FileUtils.touch ".#{dir}/pact_helper.rb"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
PACT_HELPER_FILE_DIRS = [
|
|
17
|
-
'/spec/blah/service-consumers',
|
|
18
|
-
'/spec/consumers',
|
|
19
|
-
'/spec/blah/service_consumers',
|
|
20
|
-
'/spec/serviceconsumers',
|
|
21
|
-
'/spec/consumer',
|
|
22
|
-
'/spec',
|
|
23
|
-
'/blah',
|
|
24
|
-
'/blah/consumer',
|
|
25
|
-
''
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
PACT_HELPER_FILE_DIRS.each do | dir |
|
|
29
|
-
context "the pact_helper is stored in #{dir}" do
|
|
30
|
-
it "finds the pact_helper" do
|
|
31
|
-
make_pactfile dir
|
|
32
|
-
expect(subject).to eq File.join(Dir.pwd, dir, 'pact_helper.rb')
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
context "when more than one pact_helper exists" do
|
|
38
|
-
it "returns the one that matches the most explict search pattern" do
|
|
39
|
-
make_pactfile '/spec/consumer'
|
|
40
|
-
FileUtils.touch 'pact_helper.rb'
|
|
41
|
-
expect(subject).to eq File.join(Dir.pwd, '/spec/consumer/pact_helper.rb')
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "when a file exists ending in pact_helper.rb" do
|
|
46
|
-
it "is not identifed as a pact helper" do
|
|
47
|
-
FileUtils.mkdir_p './spec'
|
|
48
|
-
FileUtils.touch './spec/not_pact_helper.rb'
|
|
49
|
-
expect { subject }.to raise_error /Please create a pact_helper.rb file/
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'pact/provider/print_missing_provider_states'
|
|
3
|
-
|
|
4
|
-
module Pact
|
|
5
|
-
module Provider
|
|
6
|
-
describe PrintMissingProviderStates do
|
|
7
|
-
|
|
8
|
-
describe "text" do
|
|
9
|
-
let(:missing_provider_states) { {'Consumer 1' => ['state1','state2'], 'Consumer 2' => ['state3']} }
|
|
10
|
-
let(:expected_output) { File.read("./spec/support/missing_provider_states_output.txt")}
|
|
11
|
-
subject { PrintMissingProviderStates.text missing_provider_states }
|
|
12
|
-
it "returns the text" do
|
|
13
|
-
expect(subject).to include expected_output
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|