pact-support 1.11.0 → 1.12.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 (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/lib/pact/consumer_contract/consumer_contract.rb +11 -0
  4. data/lib/pact/consumer_contract/interaction.rb +4 -1
  5. data/lib/pact/consumer_contract/interaction_v2_parser.rb +9 -1
  6. data/lib/pact/consumer_contract/interaction_v3_parser.rb +10 -1
  7. data/lib/pact/support/version.rb +1 -1
  8. metadata +4 -227
  9. data/.github/ISSUE_TEMPLATE.md +0 -33
  10. data/.gitignore +0 -32
  11. data/.rspec +0 -3
  12. data/.travis.yml +0 -29
  13. data/Appraisals +0 -7
  14. data/Gemfile +0 -4
  15. data/RELEASING.md +0 -5
  16. data/Rakefile +0 -4
  17. data/gemfiles/default.gemfile +0 -5
  18. data/gemfiles/ruby_under_22.gemfile +0 -8
  19. data/pact-support.gemspec +0 -39
  20. data/script/release.sh +0 -9
  21. data/script/update-pact-specification-v2 +0 -9
  22. data/spec/fixtures/interaction-with-matching-rules.json +0 -27
  23. data/spec/fixtures/multipart-form-diff.txt +0 -9
  24. data/spec/fixtures/not-a-pact.json +0 -3
  25. data/spec/fixtures/pact-http-v2.json +0 -36
  26. data/spec/fixtures/pact-http-v3.json +0 -36
  27. data/spec/integration/matching_rules_extract_and_merge_spec.rb +0 -127
  28. data/spec/lib/pact/array_like_spec.rb +0 -37
  29. data/spec/lib/pact/configuration_spec.rb +0 -61
  30. data/spec/lib/pact/consumer/request_spec.rb +0 -25
  31. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  32. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -142
  33. data/spec/lib/pact/consumer_contract/file_name_spec.rb +0 -24
  34. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  35. data/spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb +0 -25
  36. data/spec/lib/pact/consumer_contract/interaction_parser_spec.rb +0 -62
  37. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -121
  38. data/spec/lib/pact/consumer_contract/interaction_v2_parser_spec.rb +0 -54
  39. data/spec/lib/pact/consumer_contract/interaction_v3_parser_spec.rb +0 -48
  40. data/spec/lib/pact/consumer_contract/pact_file_spec.rb +0 -204
  41. data/spec/lib/pact/consumer_contract/query_hash_spec.rb +0 -154
  42. data/spec/lib/pact/consumer_contract/query_string_spec.rb +0 -131
  43. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -486
  44. data/spec/lib/pact/consumer_contract/response_spec.rb +0 -82
  45. data/spec/lib/pact/helpers_spec.rb +0 -143
  46. data/spec/lib/pact/matchers/differ_spec.rb +0 -215
  47. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  48. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  49. data/spec/lib/pact/matchers/extract_diff_messages_spec.rb +0 -78
  50. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  51. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -121
  52. data/spec/lib/pact/matchers/matchers_array_like_spec.rb +0 -222
  53. data/spec/lib/pact/matchers/matchers_messages_hash_and_array_spec.rb +0 -146
  54. data/spec/lib/pact/matchers/matchers_messages_mismatched_value_spec.rb +0 -72
  55. data/spec/lib/pact/matchers/matchers_messages_regexp_spec.rb +0 -103
  56. data/spec/lib/pact/matchers/matchers_spec.rb +0 -561
  57. data/spec/lib/pact/matchers/multipart_form_diff_formatter_spec.rb +0 -36
  58. data/spec/lib/pact/matchers/no_diff_at_index_spec.rb +0 -15
  59. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  60. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -36
  61. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  62. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  63. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -235
  64. data/spec/lib/pact/matching_rules/extract_spec.rb +0 -216
  65. data/spec/lib/pact/matching_rules/merge_spec.rb +0 -436
  66. data/spec/lib/pact/matching_rules/v3/extract_spec.rb +0 -238
  67. data/spec/lib/pact/matching_rules/v3/merge_spec.rb +0 -485
  68. data/spec/lib/pact/matching_rules_spec.rb +0 -82
  69. data/spec/lib/pact/reification_spec.rb +0 -172
  70. data/spec/lib/pact/shared/dsl_spec.rb +0 -100
  71. data/spec/lib/pact/shared/form_differ_spec.rb +0 -71
  72. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  73. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  74. data/spec/lib/pact/shared/multipart_form_differ_spec.rb +0 -49
  75. data/spec/lib/pact/shared/request_spec.rb +0 -235
  76. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  77. data/spec/lib/pact/something_like_spec.rb +0 -23
  78. data/spec/lib/pact/support_spec.rb +0 -9
  79. data/spec/lib/pact/symbolize_keys_spec.rb +0 -15
  80. data/spec/lib/pact/term_spec.rb +0 -89
  81. data/spec/pact_specification/compliance-2.0.rb +0 -66
  82. data/spec/spec_helper.rb +0 -18
  83. data/spec/support/a_consumer-a_producer.json +0 -32
  84. data/spec/support/a_consumer-a_provider.json +0 -32
  85. data/spec/support/active_support_if_configured.rb +0 -6
  86. data/spec/support/case-insensitive-response-header-matching.json +0 -21
  87. data/spec/support/consumer_contract_template.json +0 -24
  88. data/spec/support/dsl_spec_support.rb +0 -7
  89. data/spec/support/factories.rb +0 -87
  90. data/spec/support/generated_index.md +0 -4
  91. data/spec/support/generated_markdown.md +0 -55
  92. data/spec/support/interaction_view_model.json +0 -63
  93. data/spec/support/interaction_view_model_with_terms.json +0 -50
  94. data/spec/support/markdown_pact.json +0 -48
  95. data/spec/support/missing_provider_states_output.txt +0 -25
  96. data/spec/support/options.json +0 -21
  97. data/spec/support/ruby_version_helpers.rb +0 -23
  98. data/spec/support/shared_examples_for_request.rb +0 -132
  99. data/spec/support/spec_support.rb +0 -29
  100. data/spec/support/stubbing.json +0 -22
  101. data/spec/support/term.json +0 -48
  102. data/spec/support/test_app_fail.json +0 -61
  103. data/spec/support/test_app_pass.json +0 -38
  104. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  105. data/tasks/release.rake +0 -5
  106. data/tasks/spec.rake +0 -14
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/consumer/request'
3
- require 'pact/consumer_contract/request'
4
- require 'pact/matchers/embedded_diff_formatter'
5
-
6
-
7
- PACT_SPEC_DIR = "spec/support/pact-specification-v2/testcases"
8
- REQUEST_TEST_CASE_FOLDERS = Dir.glob("#{PACT_SPEC_DIR}/request/**")
9
- REQUEST_TEST_CASE_FILES = Dir.glob("#{PACT_SPEC_DIR}/request/**/*.json")
10
-
11
- TEST_DESCRIPTIONS = {true => "matches", false => "does not match"}
12
- TESTCASES = "**/*.json"
13
- # TESTCASES = "array with nested array that matches.json"
14
- describe "Pact gem complicance with Pact Specification 2.0.0" do
15
-
16
- directories = Dir.glob("#{PACT_SPEC_DIR}/request") # make this a *
17
-
18
- directories.each do | dir_name |
19
-
20
- describe File.basename(dir_name) do
21
-
22
- sub_directories = Dir.glob("#{dir_name}/*")
23
-
24
- sub_directories.each do | sub_dir_name |
25
-
26
- context File.basename(sub_dir_name) do
27
- testcases = Dir.glob("#{sub_dir_name}/#{TESTCASES}")
28
-
29
- testcases.each do | file_name |
30
-
31
- context File.basename(file_name).chomp(".json") do
32
-
33
- file_content = nil
34
- begin
35
- file_content = File.read(file_name)
36
- test_content = JSON.parse(file_content)
37
- default = {'query' => '', 'headers' => {}}
38
-
39
- request_hash = Pact::MatchingRules.merge(test_content["expected"], test_content["expected"]['matchingRules'])
40
- expected = Pact::Request::Expected.from_hash(default.merge(request_hash))
41
-
42
- # expected = Pact::Request::Expected.from_hash(default.merge(test_content["expected"]))
43
- actual = Pact::Consumer::Request::Actual.from_hash(default.merge(test_content["actual"]))
44
- expected_result = test_content.fetch("match")
45
- comment = test_content["comment"]
46
-
47
- it "#{TEST_DESCRIPTIONS[expected_result]} - #{comment}" do
48
- matches = expected.matches?(actual)
49
- if matches != expected_result
50
- puts Pact::Matchers::EmbeddedDiffFormatter.call(expected.difference(actual))
51
- end
52
- expect(matches).to eq expected_result
53
- end
54
- rescue => e
55
- puts "Error parsing json from #{file_name}, #{e.message}: #{file_content}"
56
- raise e
57
- end
58
-
59
- end
60
-
61
- end
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,18 +0,0 @@
1
- require 'fakefs/spec_helpers'
2
- require 'pact/support'
3
- require 'webmock/rspec'
4
- require 'support/factories'
5
- require 'support/spec_support'
6
-
7
- WebMock.disable_net_connect!(allow_localhost: true)
8
-
9
- require './spec/support/active_support_if_configured'
10
-
11
- RSpec.configure do | config |
12
- config.include(FakeFS::SpecHelpers, :fakefs => true)
13
-
14
- config.include Pact::SpecSupport
15
- if config.respond_to?(:example_status_persistence_file_path=)
16
- config.example_status_persistence_file_path = "./spec/examples.txt"
17
- end
18
- end
@@ -1,32 +0,0 @@
1
- {
2
- "producer": {
3
- "name": "an old producer"
4
- },
5
- "consumer": {
6
- "name": "a consumer"
7
- },
8
- "interactions": [
9
- {
10
- "description": "request one",
11
- "request": {
12
- "method": "get",
13
- "path": "/path_one"
14
- },
15
- "response": {
16
- },
17
- "producer_state": "state one"
18
- },
19
- {
20
- "description": "request two",
21
- "request": {
22
- "method": "get",
23
- "path": "/path_two"
24
- },
25
- "response": {
26
- }
27
- }
28
- ],
29
- "metadata": {
30
- "pactSpecificationVersion": "1.0"
31
- }
32
- }
@@ -1,32 +0,0 @@
1
- {
2
- "provider": {
3
- "name": "a provider"
4
- },
5
- "consumer": {
6
- "name": "a consumer"
7
- },
8
- "interactions": [
9
- {
10
- "description": "request one",
11
- "request": {
12
- "method": "get",
13
- "path": "/path_one"
14
- },
15
- "response": {
16
- },
17
- "provider_state": "state one"
18
- },
19
- {
20
- "description": "request two",
21
- "request": {
22
- "method": "get",
23
- "path": "/path_two"
24
- },
25
- "response": {
26
- }
27
- }
28
- ],
29
- "metadata": {
30
- "pactSpecificationVersion": "1.0"
31
- }
32
- }
@@ -1,6 +0,0 @@
1
- if ENV['LOAD_ACTIVE_SUPPORT']
2
- puts 'LOADING ACTIVE SUPPORT!!!! Hopefully it all still works'
3
- require 'active_support/all'
4
- require 'active_support'
5
- require 'active_support/json'
6
- end
@@ -1,21 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "an easy consumer"
4
- },
5
- "provider": {
6
- "name": "a provider which returns headers that don't match the expected case"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request",
11
- "request": {
12
- "method": "get",
13
- "path": "/"
14
- },
15
- "response": {
16
- "status": 200,
17
- "headers": {"Content-Type": "application/hippo"}
18
- }
19
- }
20
- ]
21
- }
@@ -1,24 +0,0 @@
1
- {
2
- "provider": {
3
- "name": "a provider"
4
- },
5
- "consumer": {
6
- "name": "a consumer"
7
- },
8
- "interactions": [
9
- {
10
- "description": "request one",
11
- "request": {
12
- "method": "get",
13
- "path": "/path_one"
14
- },
15
- "response": {
16
- "status" : 200
17
- },
18
- "provider_state": "state one"
19
- }
20
- ],
21
- "metadata": {
22
- "pactSpecificationVersion": "1.0"
23
- }
24
- }
@@ -1,7 +0,0 @@
1
- def global_method
2
- "I'm global"
3
- end
4
-
5
- def global_app
6
- "I'm a global app"
7
- end
@@ -1,87 +0,0 @@
1
- require 'hashie'
2
- require 'hashie/extensions/key_conversion'
3
-
4
- module Pact
5
- module HashUtils
6
-
7
- class Converter < Hash
8
- include Hashie::Extensions::KeyConversion
9
- include Hashie::Extensions::DeepMerge
10
- end
11
-
12
- def symbolize_keys hash
13
- Hash[Converter[hash].symbolize_keys]
14
- end
15
-
16
- def stringify_keys hash
17
- Hash[Converter[hash].stringify_keys]
18
- end
19
-
20
- def deep_merge hash1, hash2
21
- Converter[hash1].deep_merge(Converter[hash2])
22
- end
23
- end
24
- end
25
-
26
- class InteractionFactory
27
-
28
- extend Pact::HashUtils
29
-
30
- def self.create hash = {}
31
- defaults = {
32
- 'description' => 'a description',
33
- 'provider_state' => 'a thing exists',
34
- 'request' => {
35
- 'path' => '/path',
36
- 'method' => 'get',
37
- },
38
- 'response' => {
39
- 'status' => 200,
40
- 'body' => {a: 'response body'}
41
- }
42
- }
43
-
44
- if hash.key?(:provider_states) || hash.key?('provider_states')
45
- defaults.delete('provider_state')
46
- end
47
-
48
- Pact::Interaction.from_hash(stringify_keys(deep_merge(defaults, stringify_keys(hash))))
49
- end
50
- end
51
-
52
-
53
- class ConsumerContractFactory
54
- extend Pact::HashUtils
55
- DEFAULTS = {:consumer_name => 'consumer',
56
- :provider_name => 'provider',
57
- :interactions => [InteractionFactory.create]}
58
-
59
- def self.create overrides = {}
60
- options = deep_merge(symbolize_keys(DEFAULTS), symbolize_keys(overrides))
61
- Pact::ConsumerContract.new({:consumer => Pact::ServiceConsumer.new(name: options[:consumer_name]),
62
- :provider => Pact::ServiceProvider.new(name: options[:provider_name]),
63
- :interactions => options[:interactions]})
64
- end
65
- end
66
-
67
-
68
-
69
- class ResponseFactory
70
- extend Pact::HashUtils
71
- DEFAULTS = {:status => 200, :body => {a: 'body'}}.freeze
72
- def self.create_hash overrides = {}
73
- deep_merge(DEFAULTS, overrides)
74
- end
75
- end
76
-
77
- class RequestFactory
78
- extend Pact::HashUtils
79
- DEFAULTS = {:path => '/path', :method => 'get', :query => 'query', :headers => {}}.freeze
80
- def self.create_hash overrides = {}
81
- deep_merge(DEFAULTS, overrides)
82
- end
83
-
84
- def self.create_actual overrides = {}
85
- Pact::Consumer::Request::Actual.from_hash(create_hash(overrides))
86
- end
87
- end
@@ -1,4 +0,0 @@
1
- ### Pacts for Some Consumer
2
-
3
- * [Some Provider](Some Provider.md)
4
- * [Some other provider](Some other provider.md)
@@ -1,55 +0,0 @@
1
- ### A pact between Some Consumer and Some Provider
2
-
3
- #### Requests from Some Consumer to Some Provider
4
-
5
- * [A request for alligators](#a_request_for_alligators_given_alligators_exist) given alligators exist
6
-
7
- * [A request for polar bears](#a_request_for_polar_bears)
8
-
9
- #### Interactions
10
-
11
- <a name="a_request_for_alligators_given_alligators_exist"></a>
12
- Given **alligators exist**, upon receiving **a request for alligators** from Some Consumer, with
13
- ```json
14
- {
15
- "method": "get",
16
- "path": "/alligators"
17
- }
18
- ```
19
- Some Provider will respond with:
20
- ```json
21
- {
22
- "status": 200,
23
- "headers": {
24
- "Content-Type": "application/json"
25
- },
26
- "body": {
27
- "alligators": [
28
- {
29
- "name": "Bob",
30
- "phoneNumber": "12345678"
31
- }
32
- ]
33
- }
34
- }
35
- ```
36
- <a name="a_request_for_polar_bears"></a>
37
- Upon receiving **a request for polar bears** from Some Consumer, with
38
- ```json
39
- {
40
- "method": "get",
41
- "path": "/polar-bears"
42
- }
43
- ```
44
- Some Provider will respond with:
45
- ```json
46
- {
47
- "status": 404,
48
- "headers": {
49
- "Content-Type": "application/json"
50
- },
51
- "body": {
52
- "message": "Sorry, due to climate change, the polar bears are currently unavailable."
53
- }
54
- }
55
- ```
@@ -1,63 +0,0 @@
1
- {
2
- "provider": {
3
- "name": "a provider"
4
- },
5
- "consumer": {
6
- "name": "a consumer"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a request with a body and headers",
11
- "request": {
12
- "method": "get",
13
- "path": "/path",
14
- "query": "some=thing",
15
- "headers": {
16
- "key": "a header"
17
- },
18
- "body": {
19
- "key": "a body"
20
- }
21
- },
22
- "response": {}
23
- },
24
- {
25
- "description": "a request with an empty body and empty headers",
26
- "request": {
27
- "method": "get",
28
- "path": "/",
29
- "headers": {},
30
- "body": {}
31
- },
32
- "response": {}
33
- },
34
- {
35
- "description": "a response with a body and headers",
36
- "request": {
37
- "method": "get",
38
- "path": "/"
39
- },
40
- "response": {
41
- "headers": {
42
- "key": "a header"
43
- },
44
- "body": {
45
- "key": "a body"
46
- },
47
- "status": 200
48
- }
49
- },
50
- {
51
- "description": "a response with an empty body and empty headers",
52
- "request": {
53
- "method": "get",
54
- "path": "/"
55
- },
56
- "response": {
57
- "status": 200,
58
- "headers": {},
59
- "body": {}
60
- }
61
- }
62
- ]
63
- }
@@ -1,50 +0,0 @@
1
- {
2
- "provider": {
3
- "name": "a provider"
4
- },
5
- "consumer": {
6
- "name": "a consumer"
7
- },
8
- "interactions": [
9
- {
10
- "description": "an interaction with terms",
11
- "request": {
12
- "method": "post",
13
- "path": "/path",
14
- "query": "some=thing",
15
- "headers": {
16
- "key": "a header"
17
- },
18
- "body": {
19
- "term": {
20
- "json_class": "Pact::Term",
21
- "data": {
22
- "generate": "sunny",
23
- "matcher": {
24
- "json_class": "Regexp",
25
- "o": 0,
26
- "s": "sun"
27
- }
28
- }
29
- }
30
- }
31
- },
32
- "response": {
33
- "status": 200,
34
- "body": {
35
- "term": {
36
- "json_class": "Pact::Term",
37
- "data": {
38
- "generate": "rainy",
39
- "matcher": {
40
- "json_class": "Regexp",
41
- "o": 0,
42
- "s": "rain"
43
- }
44
- }
45
- }
46
- }
47
- }
48
- }
49
- ]
50
- }