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
data/script/release.sh DELETED
@@ -1,9 +0,0 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- git checkout -- lib/pact/support/version.rb
5
- bundle exec bump ${1:-minor} --no-commit
6
- bundle exec rake generate_changelog
7
- git add CHANGELOG.md lib/pact/support/version.rb
8
- git commit -m "chore(release): version $(ruby -r ./lib/pact/support/version.rb -e "puts Pact::Support::VERSION")"
9
- bundle exec rake release
@@ -1,9 +0,0 @@
1
- #!/bin/sh
2
-
3
- # git remote add pact-specification git@github.com:bethesque/pact-specification.git
4
- # git fetch pact-specification
5
- # git subtree add --prefix spec/support/pact-specification-v2 pact-specification/version-2 --squash
6
-
7
- git remote add pact-specification git@github.com:bethesque/pact-specification.git
8
- git fetch pact-specification
9
- git subtree pull --prefix spec/support/pact-specification-v2 pact-specification/version-2 --squash
@@ -1,27 +0,0 @@
1
- {
2
- "description": "a request to make something",
3
- "providerState" : null,
4
- "request" : {
5
- "method" : "POST",
6
- "path" : "/something",
7
- "body": {
8
- "name": "Mary"
9
- },
10
- "matchingRules": {
11
- "$.body.name" : {"regex" : ".+"}
12
- }
13
- },
14
- "response" : {
15
- "status" : 200,
16
- "body" : {
17
- "_links" : {
18
- "self" : {
19
- "href" : "http://localhost:1234/things/1"
20
- }
21
- }
22
- },
23
- "matchingRules" : {
24
- "$.body._links.self.href": {"regex": "http:\\/\\/.*\\/\\d+"}
25
- }
26
- }
27
- }
@@ -1,9 +0,0 @@
1
-
2
-
3
- Description of differences
4
- --------------------------------------
5
- * Wrong header
6
-
7
- @@ -1,2 +1,2 @@
8
- -bar
9
- +foo
@@ -1,3 +0,0 @@
1
- {
2
- "foo": "bar"
3
- }
@@ -1,36 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "some-test-consumer"
4
- },
5
- "provider": {
6
- "name": "an unknown provider"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request",
11
- "request": {
12
- "method": "get",
13
- "path": "/weather",
14
- "query": ""
15
- },
16
- "response": {
17
- "matchingRules": {
18
- "$.headers.Content-Type" : {
19
- "match": "regex", "regex": "json"
20
- },
21
- "$.body.message" : {
22
- "match": "regex", "regex": "sun"
23
- }
24
- },
25
- "status": 200,
26
- "headers" : {
27
- "Content-Type": "foo/json"
28
- },
29
- "body": {
30
- "message" : "sunful"
31
- }
32
- },
33
- "provider_state": "the weather is sunny"
34
- }
35
- ]
36
- }
@@ -1,36 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "consumer"
4
- },
5
- "interactions": [
6
- {
7
- "description": "a test request",
8
- "providerState": "the weather is sunny",
9
- "request": {
10
- "method": "get",
11
- "path": "/foo"
12
- },
13
- "response": {
14
- "body": {
15
- "foo": "bar"
16
- },
17
- "matchingRules": {
18
- "body": {
19
- "$.foo": {
20
- "matchers": [{ "match": "type" }]
21
- }
22
- }
23
- },
24
- "status": 200
25
- }
26
- }
27
- ],
28
- "provider": {
29
- "name": "provider"
30
- },
31
- "metadata": {
32
- "pactSpecification": {
33
- "version": "3.0"
34
- }
35
- }
36
- }
@@ -1,127 +0,0 @@
1
- require 'pact/term'
2
- require 'pact/something_like'
3
- require 'pact/matching_rules/extract'
4
- require 'pact/matching_rules/v3/extract'
5
- require 'pact/matching_rules/merge'
6
- require 'pact/matching_rules/v3/merge'
7
- require 'pact/reification'
8
-
9
- describe "converting Pact::Term and Pact::SomethingLike to matching rules and back again" do
10
-
11
- let(:example) { Pact::Reification.from_term expected }
12
- let(:matching_rules) { Pact::MatchingRules::Extract.(expected) }
13
- let(:recreated_expected) { Pact::MatchingRules::Merge.(example, matching_rules)}
14
-
15
- let(:recreated_expected_v3) { Pact::MatchingRules::V3::Merge.(example, matching_rules_v3) }
16
- let(:matching_rules_v3) { Pact::MatchingRules::V3::Extract.(expected) }
17
-
18
- context "with a Pact::Term" do
19
- let(:expected) do
20
- {
21
- body: {
22
- alligator: {
23
- name: Pact::Term.new(generate: 'Mary', matcher: /M/)
24
- }
25
- }
26
- }
27
- end
28
-
29
- it "recreates the same object hierarchy with v2 matching" do
30
- expect(recreated_expected).to eq expected
31
- end
32
-
33
- it "recreates the same object hierarchy with v3 matching" do
34
- expect(recreated_expected_v3).to eq expected
35
- end
36
- end
37
-
38
- context "with a Pact::SomethingLike containing a Pact::ArrayLike" do
39
- let(:expected) do
40
- {
41
- body: Pact::SomethingLike.new(children: Pact::ArrayLike.new("foo", min: 2))
42
- }
43
- end
44
-
45
- it "recreates the same object hierarchy with v2 matching" do
46
- expect(recreated_expected).to eq expected
47
- end
48
-
49
- it "recreates the same object hierarchy with v3 matching" do
50
- expect(recreated_expected_v3).to eq expected
51
- end
52
- end
53
-
54
- context "with a Pact::SomethingLike" do
55
- let(:expected) do
56
- {
57
- body: {
58
- alligator: {
59
- name: Pact::SomethingLike.new("Mary")
60
- }
61
- }
62
- }
63
- end
64
-
65
- it "recreates the same object hierarchy with v2 matching" do
66
- expect(recreated_expected).to eq expected
67
- end
68
-
69
- it "recreates the same object hierarchy with v3 matching" do
70
- expect(recreated_expected_v3).to eq expected
71
- end
72
- end
73
-
74
- context "with a Pact::SomethingLike containing a Hash" do
75
- let(:expected) do
76
- {
77
- body: {
78
- alligator: Pact::SomethingLike.new(name: 'Mary')
79
- }
80
- }
81
- end
82
-
83
- let(:similar) do
84
- {
85
- body: {
86
- alligator: {
87
- name: Pact::SomethingLike.new('Mary')
88
- }
89
- }
90
- }
91
- end
92
-
93
- it "recreates the same object hierarchy with v2 matching" do
94
- expect(recreated_expected).to eq expected
95
- end
96
-
97
- it "recreates the same object hierarchy with v3 matching" do
98
- expect(recreated_expected_v3).to eq expected
99
- end
100
- end
101
-
102
- context "with a Pact::SomethingLike containing an Array" do
103
- let(:expected) do
104
- {
105
- body: {
106
- alligators: Pact::SomethingLike.new(["Mary", "Betty"])
107
- }
108
- }
109
- end
110
-
111
- let(:similar) do
112
- {
113
- body: {
114
- alligators: [Pact::SomethingLike.new("Mary"), Pact::SomethingLike.new("Betty")]
115
- }
116
- }
117
- end
118
-
119
- it "recreates the same object hierarchy with v2 matching" do
120
- expect(recreated_expected).to eq expected
121
- end
122
-
123
- it "recreates the same object hierarchy with v3 matching" do
124
- expect(recreated_expected_v3).to eq expected
125
- end
126
- end
127
- end
@@ -1,37 +0,0 @@
1
- require 'pact/array_like'
2
-
3
- module Pact
4
- describe ArrayLike do
5
-
6
- describe "#eq" do
7
- subject { ArrayLike.new({name: 'Fred'}, {min: 3}) }
8
- context "when the contents and min are the same" do
9
- let(:other) { ArrayLike.new({name: 'Fred'}, {min: 3}) }
10
- it "returns true" do
11
- expect(subject).to eq other
12
- end
13
-
14
- end
15
- context "when the contents are different" do
16
- let(:other) { ArrayLike.new({name: 'John'}, {min: 3}) }
17
- it "returns false" do
18
- expect(subject).to_not eq other
19
- end
20
- end
21
- context "when the min is different" do
22
- let(:other) { ArrayLike.new({name: 'Fred'}, {min: 1}) }
23
- it "returns false" do
24
- expect(subject).to_not eq other
25
- end
26
- end
27
- end
28
-
29
- subject { ArrayLike.new({name: Pact::Term.new(generate: 'Fred', matcher: /F/)}, {min: 2}) }
30
-
31
- describe "#generate" do
32
- it "creates an array with the reified example" do
33
- expect(subject.generate).to eq [{name: 'Fred'},{name: 'Fred'}]
34
- end
35
- end
36
- end
37
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/configuration'
3
-
4
- module Pact
5
-
6
- describe Configuration do
7
-
8
- subject { Configuration.default_configuration }
9
-
10
- describe "#color_enabled" do
11
-
12
- it "sets color_enabled to be true by default" do
13
- expect(subject.color_enabled).to be true
14
- end
15
-
16
- it "allows configuration of colour_enabled" do
17
- subject.color_enabled = false
18
- expect(subject.color_enabled).to be false
19
- end
20
-
21
- end
22
-
23
- describe "#pactfile_write_order" do
24
- it "sets pactfile_write_order to chronological by default" do
25
- expect(subject.pactfile_write_order).to eq(:chronological)
26
- end
27
-
28
- it "allows configuration of pactfile_write_order" do
29
- subject.pactfile_write_order = :alphabetical
30
- expect(subject.pactfile_write_order).to eq(:alphabetical)
31
- end
32
- end
33
-
34
- describe "#body_differ_for_content_type" do
35
- context "when the Content-Type is nil" do
36
-
37
- before do
38
- allow(Pact.configuration.error_stream).to receive(:puts)
39
- end
40
-
41
- subject { Pact.configuration.body_differ_for_content_type nil }
42
-
43
- it "returns the TextDiffer" do
44
- expect(subject).to eq Pact::TextDiffer
45
- end
46
-
47
- it "logs a warning to log file" do
48
- expect(Pact.configuration.logger).to receive(:warn).with(/No content type found/)
49
- subject
50
- end
51
-
52
- it "logs a warning to the error stream" do
53
- expect(Pact.configuration.error_stream).to receive(:puts).with(/WARN: No content type found/)
54
- subject
55
- end
56
-
57
- end
58
- end
59
-
60
- end
61
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/shared_examples_for_request'
3
- require 'pact/consumer/request'
4
-
5
- module Pact
6
- describe Consumer::Request::Actual do
7
- it_behaves_like "a request"
8
-
9
- let(:raw_request) do
10
- {
11
- 'method' => 'get',
12
- 'path' => '/mallory'
13
- }
14
- end
15
-
16
- describe "from_hash" do
17
- context "when field are not defined" do
18
- subject { described_class.from_hash(raw_request) }
19
- it "raises an error" do
20
- expect{subject}.to raise_error KeyError
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/active_support_support'
3
-
4
- module Pact
5
- describe ActiveSupportSupport do
6
-
7
- include ActiveSupportSupport
8
-
9
-
10
- describe "fix_regexp" do
11
- let(:regexp) { /moose/ }
12
-
13
- subject { fix_regexp regexp }
14
-
15
- it "returns the original regexp" do
16
- expect(subject).to be(regexp)
17
- end
18
-
19
- it "fixes the as_json method for Regexp that ActiveSupport tramples beneath its destructive hooves of destruction" do
20
- expect(subject.to_json).to eq("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"moose\"}")
21
- end
22
- end
23
-
24
- describe "fix_all_the_things" do
25
- let(:hash) do
26
- { 'body' => Pact::Term.new(matcher: /a*b/, generate: 'abba'), array: [/blah/], thing: /alligator/ }
27
- end
28
-
29
- subject { fix_all_the_things(hash) }
30
-
31
- it "returns the original object" do
32
- expect(subject).to be(hash)
33
- end
34
-
35
- it "finds all the Regexp objects in hashes or Pact class attributes and fixes the as_json method" do
36
- json = subject.to_json
37
- expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"a*b\"}")
38
- expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"blah\"}")
39
- expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"alligator\"}")
40
- end
41
- end
42
-
43
- describe "fix_json_formatting" do
44
- let(:active_support_affected_pretty_generated_json) { "{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"a*b\"}" }
45
- let(:pretty_generated_json) do
46
- '{
47
- "json_class": "Regexp",
48
- "o": 0,
49
- "s": "a*b"
50
- }'
51
- end
52
-
53
- it "pretty formats the json that has been not pretty formatted because of ActiveSupport" do
54
- expect(fix_json_formatting(active_support_affected_pretty_generated_json)).to eq (pretty_generated_json.strip)
55
- end
56
- end
57
- end
58
- end