pact-support 1.9.0 → 1.15.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.
Files changed (112) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +124 -0
  3. data/lib/pact/configuration.rb +7 -0
  4. data/lib/pact/consumer_contract/consumer_contract.rb +12 -1
  5. data/lib/pact/consumer_contract/http_consumer_contract_parser.rb +1 -1
  6. data/lib/pact/consumer_contract/interaction.rb +5 -1
  7. data/lib/pact/consumer_contract/interaction_v2_parser.rb +9 -1
  8. data/lib/pact/consumer_contract/interaction_v3_parser.rb +22 -3
  9. data/lib/pact/consumer_contract/pact_file.rb +32 -1
  10. data/lib/pact/matchers/matchers.rb +33 -13
  11. data/lib/pact/matching_rules/v3/merge.rb +4 -2
  12. data/lib/pact/shared/multipart_form_differ.rb +2 -0
  13. data/lib/pact/support/version.rb +1 -1
  14. data/lib/pact/term.rb +0 -1
  15. metadata +5 -228
  16. data/.gitignore +0 -32
  17. data/.rspec +0 -3
  18. data/.travis.yml +0 -29
  19. data/Appraisals +0 -7
  20. data/Gemfile +0 -4
  21. data/RELEASING.md +0 -5
  22. data/Rakefile +0 -4
  23. data/gemfiles/default.gemfile +0 -5
  24. data/gemfiles/ruby_under_22.gemfile +0 -8
  25. data/pact-support.gemspec +0 -39
  26. data/script/release.sh +0 -9
  27. data/script/update-pact-specification-v2 +0 -9
  28. data/spec/fixtures/interaction-with-matching-rules.json +0 -27
  29. data/spec/fixtures/multipart-form-diff.txt +0 -9
  30. data/spec/fixtures/not-a-pact.json +0 -3
  31. data/spec/fixtures/pact-http-v2.json +0 -36
  32. data/spec/fixtures/pact-http-v3.json +0 -36
  33. data/spec/integration/matching_rules_extract_and_merge_spec.rb +0 -127
  34. data/spec/lib/pact/array_like_spec.rb +0 -37
  35. data/spec/lib/pact/configuration_spec.rb +0 -61
  36. data/spec/lib/pact/consumer/request_spec.rb +0 -25
  37. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  38. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -142
  39. data/spec/lib/pact/consumer_contract/file_name_spec.rb +0 -24
  40. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  41. data/spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb +0 -25
  42. data/spec/lib/pact/consumer_contract/interaction_parser_spec.rb +0 -62
  43. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -121
  44. data/spec/lib/pact/consumer_contract/interaction_v2_parser_spec.rb +0 -54
  45. data/spec/lib/pact/consumer_contract/interaction_v3_parser_spec.rb +0 -48
  46. data/spec/lib/pact/consumer_contract/pact_file_spec.rb +0 -204
  47. data/spec/lib/pact/consumer_contract/query_hash_spec.rb +0 -154
  48. data/spec/lib/pact/consumer_contract/query_string_spec.rb +0 -131
  49. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -486
  50. data/spec/lib/pact/consumer_contract/response_spec.rb +0 -82
  51. data/spec/lib/pact/helpers_spec.rb +0 -143
  52. data/spec/lib/pact/matchers/differ_spec.rb +0 -215
  53. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  54. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  55. data/spec/lib/pact/matchers/extract_diff_messages_spec.rb +0 -78
  56. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  57. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -121
  58. data/spec/lib/pact/matchers/matchers_array_like_spec.rb +0 -222
  59. data/spec/lib/pact/matchers/matchers_messages_hash_and_array_spec.rb +0 -146
  60. data/spec/lib/pact/matchers/matchers_messages_mismatched_value_spec.rb +0 -71
  61. data/spec/lib/pact/matchers/matchers_messages_regexp_spec.rb +0 -103
  62. data/spec/lib/pact/matchers/matchers_spec.rb +0 -521
  63. data/spec/lib/pact/matchers/multipart_form_diff_formatter_spec.rb +0 -36
  64. data/spec/lib/pact/matchers/no_diff_at_index_spec.rb +0 -15
  65. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  66. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -36
  67. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  68. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  69. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -235
  70. data/spec/lib/pact/matching_rules/extract_spec.rb +0 -216
  71. data/spec/lib/pact/matching_rules/merge_spec.rb +0 -436
  72. data/spec/lib/pact/matching_rules/v3/extract_spec.rb +0 -238
  73. data/spec/lib/pact/matching_rules/v3/merge_spec.rb +0 -485
  74. data/spec/lib/pact/matching_rules_spec.rb +0 -82
  75. data/spec/lib/pact/reification_spec.rb +0 -172
  76. data/spec/lib/pact/shared/dsl_spec.rb +0 -100
  77. data/spec/lib/pact/shared/form_differ_spec.rb +0 -71
  78. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  79. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  80. data/spec/lib/pact/shared/multipart_form_differ_spec.rb +0 -39
  81. data/spec/lib/pact/shared/request_spec.rb +0 -235
  82. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  83. data/spec/lib/pact/something_like_spec.rb +0 -23
  84. data/spec/lib/pact/support_spec.rb +0 -9
  85. data/spec/lib/pact/symbolize_keys_spec.rb +0 -15
  86. data/spec/lib/pact/term_spec.rb +0 -89
  87. data/spec/pact_specification/compliance-2.0.rb +0 -66
  88. data/spec/spec_helper.rb +0 -18
  89. data/spec/support/a_consumer-a_producer.json +0 -32
  90. data/spec/support/a_consumer-a_provider.json +0 -32
  91. data/spec/support/active_support_if_configured.rb +0 -6
  92. data/spec/support/case-insensitive-response-header-matching.json +0 -21
  93. data/spec/support/consumer_contract_template.json +0 -24
  94. data/spec/support/dsl_spec_support.rb +0 -7
  95. data/spec/support/factories.rb +0 -87
  96. data/spec/support/generated_index.md +0 -4
  97. data/spec/support/generated_markdown.md +0 -55
  98. data/spec/support/interaction_view_model.json +0 -63
  99. data/spec/support/interaction_view_model_with_terms.json +0 -50
  100. data/spec/support/markdown_pact.json +0 -48
  101. data/spec/support/missing_provider_states_output.txt +0 -25
  102. data/spec/support/options.json +0 -21
  103. data/spec/support/ruby_version_helpers.rb +0 -23
  104. data/spec/support/shared_examples_for_request.rb +0 -132
  105. data/spec/support/spec_support.rb +0 -29
  106. data/spec/support/stubbing.json +0 -22
  107. data/spec/support/term.json +0 -48
  108. data/spec/support/test_app_fail.json +0 -61
  109. data/spec/support/test_app_pass.json +0 -38
  110. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  111. data/tasks/release.rake +0 -5
  112. data/tasks/spec.rake +0 -14
@@ -1,90 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/matchers/embedded_diff_formatter'
3
- require 'pact/matchers/type_difference'
4
- require 'pact/matchers/expected_type'
5
- require 'pact/matchers/actual_type'
6
-
7
- module Pact
8
- module Matchers
9
- describe EmbeddedDiffFormatter do
10
-
11
- let(:diff) do
12
- {
13
- :something => TypeDifference.new(ExpectedType.new("Fred"), ActualType.new(1))
14
- }
15
- end
16
-
17
- subject { EmbeddedDiffFormatter.call(diff, options) }
18
-
19
- let(:options) { { colour: colour }}
20
- let(:expected_coloured) { '"' + ::Term::ANSIColor.red("expected_type") + '":'}
21
- let(:actual_coloured) { '"' + ::Term::ANSIColor.green("actual_type") + '":'}
22
-
23
- describe ".call" do
24
-
25
- let(:colour) { false }
26
-
27
- context "when color_enabled is true" do
28
-
29
- let(:colour) { true }
30
-
31
- it "returns nicely formatted json" do
32
- expect(subject.split("\n").size).to eq 6
33
- end
34
-
35
- it "returns a string displaying the diff in colour" do
36
- expect(subject).to include expected_coloured
37
- expect(subject).to include actual_coloured
38
- end
39
- end
40
-
41
- context "when color_enabled is false" do
42
-
43
- let(:colour) { false }
44
-
45
- it "returns nicely formatted json" do
46
- expect(subject.split("\n").size).to eq 6
47
- end
48
-
49
- it "returns a string displaying the diff without colour" do
50
- expect(subject).to_not include expected_coloured
51
- expect(subject).to_not include actual_coloured
52
- end
53
- end
54
-
55
- context "with a Pact::Term" do
56
- let(:diff) { {thing: Difference.new(Pact::Term.new(generate: "Joe", matcher: /Jo/), "Mary")} }
57
-
58
- xit "displays the matcher from the Pact::Term" do
59
- expect(subject).to_not include("Pact::Term")
60
- expect(subject).to include("/Jo/")
61
- end
62
-
63
- end
64
-
65
- context "when no options are specified" do
66
- subject { EmbeddedDiffFormatter.call(diff) }
67
-
68
- context "when Pact.configuration.color_enabled is true" do
69
- it "returns a string displaying the diff in colour" do
70
- expect(Pact.configuration).to receive(:color_enabled).and_return(true)
71
- expect(subject).to include expected_coloured
72
- expect(subject).to include actual_coloured
73
- end
74
- end
75
-
76
- context "when Pact.configuration.color_enabled is false" do
77
- it "returns a string displaying the diff without colour" do
78
- expect(Pact.configuration).to receive(:color_enabled).and_return(false)
79
- expect(subject).to_not include expected_coloured
80
- expect(subject).to_not include actual_coloured
81
- end
82
- end
83
-
84
- end
85
- end
86
-
87
- end
88
-
89
- end
90
- end
@@ -1,78 +0,0 @@
1
- require 'pact/matchers/extract_diff_messages'
2
-
3
- module Pact
4
- module Matchers
5
- describe ExtractDiffMessages do
6
-
7
- subject { ExtractDiffMessages.call(diff).join("\n") }
8
-
9
- context "<path> with a diff in a Hash" do
10
- let(:diff) { {a: Difference.new(nil, nil, "There was a difference at <path>") } }
11
-
12
- it { is_expected.to eq "There was a difference at $.a" }
13
- end
14
-
15
- context "<parent_path> with a diff in a Hash" do
16
- let(:diff) { {a: Difference.new(nil, nil, "There was a difference at <parent_path>") } }
17
-
18
- it { is_expected.to eq "There was a difference at $" }
19
- end
20
-
21
- context "<path> with a diff in a nested Hash" do
22
- let(:diff) { {a: {b: Difference.new(nil, nil, "There was a difference at <path>")}} }
23
-
24
- it { is_expected.to eq "There was a difference at $.a.b" }
25
- end
26
-
27
- context "<parent_path> with a diff in a nested Hash" do
28
- let(:diff) { {a: {b: Difference.new(nil, nil, "There was a difference at <parent_path>")}} }
29
-
30
- it { is_expected.to eq "There was a difference at $.a" }
31
- end
32
-
33
- context "<path> with a diff in an Array" do
34
- let(:diff) { [NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <path>")] }
35
-
36
- it { is_expected.to eq "There was a difference at $[1]" }
37
- end
38
-
39
- context "<parent_path> with a diff in an Array" do
40
- let(:diff) { [NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <parent_path>")] }
41
-
42
- it { is_expected.to eq "There was a difference at $" }
43
- end
44
-
45
- context "<path> with a diff in a nested Array" do
46
- let(:diff) { [NoDiffAtIndex.new,[NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <path>")]] }
47
-
48
- it { is_expected.to eq "There was a difference at $[1][1]" }
49
- end
50
-
51
- context "<parent_path> with a diff in a nested Array" do
52
- let(:diff) { [NoDiffAtIndex.new,[NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <parent_path>")]] }
53
-
54
- it { is_expected.to eq "There was a difference at $[1]" }
55
- end
56
-
57
- context "when there is a space in the key" do
58
- let(:diff) do
59
- {"Foo Bar" => Difference.new(nil, nil, "There was a difference at <path>")}
60
- end
61
-
62
- it { is_expected.to eq "There was a difference at $.\"Foo Bar\"" }
63
- end
64
-
65
- context "with two differences" do
66
- let(:diff) do
67
- {
68
- a: Difference.new(nil, nil, "There was a difference at <path>"),
69
- b: Difference.new(nil, nil, "There was a difference at <path>")
70
- }
71
- end
72
-
73
- it { is_expected.to eq "There was a difference at $.a\nThere was a difference at $.b" }
74
- end
75
-
76
- end
77
- end
78
- 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,121 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/matchers/list_diff_formatter'
3
- require 'pact/matchers/matchers'
4
- require 'support/ruby_version_helpers'
5
-
6
- # Needed to stop the ai printing in color
7
- # TODO: fix this!
8
- AwesomePrint.defaults = {
9
- plain: true
10
- }
11
-
12
- module Pact
13
- module Matchers
14
- describe ListDiffFormatter do
15
-
16
- describe ".call" do
17
- subject{ ListDiffFormatter.call(diff, {}) }
18
-
19
- context "when using class based matching" do
20
- let(:diff) { {root: TypeDifference.new(ExpectedType.new("Fred"), ActualType.new(1)) } }
21
- let(:expected_output) { <<-EOS
22
- \tAt:
23
- \t\t[:root]
24
- \tExpected type:
25
- \t\tString
26
- \tActual type:
27
- \t\t#{RubyVersionHelpers.numeric_type}
28
- EOS
29
- }
30
-
31
- it "shows the expected and actual classes" do
32
- expect(subject + "\n").to eq(expected_output)
33
- end
34
-
35
- end
36
-
37
- context "when there is an unmatched regexp" do
38
- let(:diff) { {root: RegexpDifference.new(/fr.*ed/, "mary") } }
39
- let(:expected_output) { <<-EOS
40
- \tAt:
41
- \t\t[:root]
42
- \tExpected to match:
43
- \t\t/fr.*ed/
44
- \tActual:
45
- \t\t"mary"
46
- EOS
47
- }
48
- it "shows the expected regexp" do
49
- expect(subject + "\n").to eq(expected_output)
50
- end
51
- end
52
-
53
- context "when there is a mismatched value" do
54
- let(:diff) { {root: {"blah" => { 1 => Difference.new("alphabet", "woozle")}}} }
55
- let(:expected_output) { ""}
56
-
57
- it "includes the expected value" do
58
- expect(subject).to match(/Expected:.*"alphabet"/m)
59
- end
60
- it "includes the actual value" do
61
- expect(subject).to match(/Actual:.*"woozle"/m)
62
- end
63
-
64
- it "includes the path" do
65
- expect(subject).to include('[:root]["blah"][1]')
66
- end
67
- end
68
-
69
- context "when there is a missing key" do
70
- let(:expected_hash) { {"abc" => {"def" => [1,2]}}}
71
- let(:diff) { {root: {"blah" => { 1 => Difference.new(expected_hash, Pact::KeyNotFound.new )}}} }
72
- let(:expected_output) { ""}
73
-
74
- it "includes the expected value" do
75
- expect(subject).to match(/Missing key with value\:.*\{/m)
76
- end
77
-
78
- it "includes the path" do
79
- expect(subject).to include('[:root]["blah"][1]')
80
- end
81
- end
82
-
83
- context "when there is a missing index" do
84
- let(:diff) { [NoDiffAtIndex.new, Difference.new(1, IndexNotFound.new )]}
85
- it "includes the expected value" do
86
- expect(subject).to match(/Missing.*1/m)
87
- end
88
-
89
- it "includes the path" do
90
- expect(subject).to include('[1]')
91
- end
92
- end
93
-
94
- context "when there is an unexpected index" do
95
- let(:diff) { [NoDiffAtIndex.new, Difference.new(UnexpectedIndex.new, 2), Difference.new(UnexpectedIndex.new, "b")]}
96
- it "includes the unexpected value" do
97
- expect(subject).to include("Array contained unexpected item:")
98
- end
99
-
100
- it "includes the path" do
101
- expect(subject).to include('[1]')
102
- expect(subject).to include('[2]')
103
- end
104
- end
105
-
106
- context "when there is an unexpected key" do
107
- let(:diff) { {"blah" => Difference.new(UnexpectedKey.new, "b")}}
108
- it "includes the unexpected key" do
109
- expect(subject).to include("Hash contained unexpected key with value:")
110
- end
111
-
112
- it "includes the path" do
113
- expect(subject).to include('["blah"]')
114
- end
115
- end
116
-
117
- end
118
-
119
- end
120
- end
121
- end
@@ -1,222 +0,0 @@
1
- require 'pact/matchers'
2
-
3
- module Pact
4
- describe Matchers do
5
-
6
- let(:min) { 1 }
7
- let(:expected) do
8
- {
9
- animals: Pact::ArrayLike.new({name: 'Fred'}, {min: min})
10
- }
11
- end
12
-
13
- let(:difference) { Pact::Matchers.diff(expected, actual) }
14
-
15
- context "when each element in the array matches by type" do
16
- let(:actual) do
17
- {
18
- animals: [{name: 'Susan'}, {name: 'Janet'}]
19
- }
20
- end
21
- it "matches" do
22
- expect(difference).to be_empty
23
- end
24
- end
25
-
26
- context "when each element in the array does not match by type" do
27
- let(:actual) do
28
- {
29
- animals: [{name: 'Susan'}, {name: 1}]
30
- }
31
- end
32
- let(:expected_difference) do
33
- {
34
- animals: [
35
- Pact::Matchers::NoDiffAtIndex.new,
36
- {
37
- name: Pact::Matchers::TypeDifference.new(ExpectedType.new('Fred'), ActualType.new(1))
38
- }
39
- ]
40
- }
41
- end
42
- it "returns a diff" do
43
- expect(difference).to eq expected_difference
44
- end
45
- end
46
-
47
- context "when an ArrayLike is expected but a hash is found" do
48
- let(:actual) do
49
- {
50
- animals: {
51
- some: 'Animals'
52
- }
53
- }
54
- end
55
- let(:expected_difference) do
56
- {
57
- animals: Matchers::Difference.new([{name: 'Fred'}], {some: 'Animals'})
58
- }
59
- end
60
- it "returns a diff" do
61
- expect(difference).to eq expected_difference
62
- end
63
- end
64
-
65
- context "when an ArrayLike is expected but nil found" do
66
- let(:actual) do
67
- {
68
- animals: nil
69
- }
70
- end
71
- let(:expected_difference) do
72
- {
73
- animals: Matchers::Difference.new([{name: 'Fred'}], nil)
74
- }
75
- end
76
- it "returns a diff" do
77
- expect(difference).to eq expected_difference
78
- end
79
- end
80
-
81
- context "when an ArrayLike is expected but an empty array is found" do
82
- let(:actual) do
83
- {
84
- animals: []
85
- }
86
- end
87
- let(:expected_difference) do
88
- {
89
- animals: [Matchers::Difference.new({name: 'Fred'}, Pact::IndexNotFound.new)]
90
- }
91
- end
92
- it "returns a diff" do
93
- expect(difference).to eq expected_difference
94
- end
95
- end
96
-
97
- context "when an ArrayLike is expected but a hash is found" do
98
- let(:actual) do
99
- {
100
-
101
- }
102
- end
103
- let(:expected_difference) do
104
- {
105
- animals: Matchers::Difference.new([{name: 'Fred'}], Pact::KeyNotFound.new)
106
- }
107
- end
108
-
109
- it "returns a diff" do
110
- expect(difference).to eq expected_difference
111
- end
112
- end
113
-
114
- context "when an ArrayLike is expected but the actual does not have enough elements in it" do
115
- let(:min) { 2 }
116
- let(:actual) do
117
- {
118
- animals: [{name: 'Susan'}]
119
- }
120
- end
121
- let(:expected_difference) do
122
- {
123
- animals: [Pact::Matchers::NoDiffAtIndex.new, Matchers::Difference.new({name: 'Fred'}, Pact::IndexNotFound.new)]
124
- }
125
- end
126
- it "returns a diff" do
127
- expect(difference).to eq expected_difference
128
- end
129
- end
130
-
131
- context "when an ArrayLike is expected with a Pact::Term in it" do
132
- let(:expected) do
133
- {
134
- animals: Pact::ArrayLike.new(name: Pact::Term.new(generate: 'Fred', matcher: /F/))
135
- }
136
- end
137
- let(:actual) do
138
- {
139
- animals: [{name: 'Susan'}]
140
- }
141
- end
142
- let(:expected_difference) do
143
- {
144
- animals: [{name: Matchers::RegexpDifference.new(/F/, 'Susan')}]
145
- }
146
- end
147
- it "returns a diff" do
148
- expect(difference).to eq expected_difference
149
- end
150
- end
151
-
152
- context "when an ArrayLike is expected within an ArrayLike and they match" do
153
- let(:expected) do
154
- {
155
- animals: Pact::ArrayLike.new(
156
- name: 'Fred',
157
- children: Pact::ArrayLike.new(
158
- age: 8
159
- )
160
- )
161
- }
162
- end
163
- let(:actual) do
164
- {
165
- animals: [
166
- {
167
- name: 'Susan',
168
- children: [
169
- {age: 4},{age: 5}
170
- ]
171
- }
172
- ]
173
- }
174
- end
175
- it "returns an empty diff" do
176
- expect(difference).to be_empty
177
- end
178
- end
179
-
180
- context "when an ArrayLike is expected within an ArrayLike and they don't match" do
181
- let(:expected) do
182
- {
183
- animals: Pact::ArrayLike.new(
184
- name: 'Fred',
185
- children: Pact::ArrayLike.new(
186
- age: 8
187
- )
188
- )
189
- }
190
- end
191
- let(:actual) do
192
- {
193
- animals: [
194
- {
195
- name: 'Susan',
196
- children: [
197
- {age: 4},{foo: 'bar'}
198
- ]
199
- }
200
- ]
201
- }
202
- end
203
- let(:expected_difference) do
204
- {
205
- animals: [
206
- {
207
- children: [
208
- Matchers::NoDiffAtIndex.new,
209
- {
210
- age: Matchers::TypeDifference.new(ExpectedType.new(8), KeyNotFound.new)
211
- }
212
- ]
213
- }
214
- ]
215
- }
216
- end
217
- it "returns the diff" do
218
- expect(difference).to eq expected_difference
219
- end
220
- end
221
- end
222
- end