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.
Files changed (212) hide show
  1. data/CHANGELOG.md +37 -1
  2. data/lib/pact/cli.rb +0 -26
  3. data/lib/pact/consumer/configuration/configuration_extensions.rb +51 -0
  4. data/lib/pact/consumer/configuration/mock_service.rb +2 -1
  5. data/lib/pact/consumer/configuration.rb +0 -1
  6. data/lib/pact/consumer/consumer_contract_builder.rb +3 -3
  7. data/lib/pact/consumer/interaction_builder.rb +3 -5
  8. data/lib/pact/doc/interaction_view_model.rb +9 -6
  9. data/lib/pact/doc/sort_interactions.rb +1 -1
  10. data/lib/pact/provider/configuration/configuration_extension.rb +0 -9
  11. data/lib/pact/provider/rspec.rb +11 -9
  12. data/lib/pact/version.rb +1 -1
  13. data/lib/pact.rb +6 -5
  14. data/pact.gemspec +6 -2
  15. metadata +57 -304
  16. data/.gitignore +0 -29
  17. data/.rspec +0 -2
  18. data/.ruby-version +0 -1
  19. data/.travis.yml +0 -8
  20. data/Gemfile +0 -4
  21. data/Gemfile.lock +0 -86
  22. data/README.md +0 -313
  23. data/Rakefile +0 -9
  24. data/config.ru +0 -3
  25. data/documentation/README.md +0 -13
  26. data/documentation/configuration.md +0 -166
  27. data/documentation/diff_formatter_embedded.png +0 -0
  28. data/documentation/diff_formatter_list.png +0 -0
  29. data/documentation/diff_formatter_unix.png +0 -0
  30. data/example/animal-service/Gemfile +0 -14
  31. data/example/animal-service/Gemfile.lock +0 -69
  32. data/example/animal-service/Rakefile +0 -5
  33. data/example/animal-service/config.ru +0 -3
  34. data/example/animal-service/db/animal_db.sqlite3 +0 -0
  35. data/example/animal-service/lib/animal_service/animal_repository.rb +0 -12
  36. data/example/animal-service/lib/animal_service/api.rb +0 -28
  37. data/example/animal-service/lib/animal_service/db.rb +0 -5
  38. data/example/animal-service/spec/service_consumers/pact_helper.rb +0 -11
  39. data/example/animal-service/spec/service_consumers/provider_states_for_zoo_app.rb +0 -26
  40. data/example/zoo-app/Gemfile +0 -12
  41. data/example/zoo-app/Gemfile.lock +0 -63
  42. data/example/zoo-app/Rakefile +0 -5
  43. data/example/zoo-app/doc/pacts/markdown/README.md +0 -3
  44. data/example/zoo-app/doc/pacts/markdown/Zoo App - Animal Service.md +0 -75
  45. data/example/zoo-app/lib/zoo_app/animal_service_client.rb +0 -40
  46. data/example/zoo-app/lib/zoo_app/models/alligator.rb +0 -15
  47. data/example/zoo-app/spec/pacts/zoo_app-animal_service.json +0 -67
  48. data/example/zoo-app/spec/service_providers/animal_service_client_spec.rb +0 -71
  49. data/example/zoo-app/spec/service_providers/pact_helper.rb +0 -15
  50. data/example/zoo-app/spec/spec_helper.rb +0 -6
  51. data/lib/pact/configuration.rb +0 -195
  52. data/lib/pact/consumer/app_manager.rb +0 -158
  53. data/lib/pact/consumer/interactions_filter.rb +0 -48
  54. data/lib/pact/consumer/mock_service/app.rb +0 -82
  55. data/lib/pact/consumer/mock_service/interaction_delete.rb +0 -33
  56. data/lib/pact/consumer/mock_service/interaction_list.rb +0 -76
  57. data/lib/pact/consumer/mock_service/interaction_mismatch.rb +0 -73
  58. data/lib/pact/consumer/mock_service/interaction_post.rb +0 -31
  59. data/lib/pact/consumer/mock_service/interaction_replay.rb +0 -139
  60. data/lib/pact/consumer/mock_service/log_get.rb +0 -28
  61. data/lib/pact/consumer/mock_service/missing_interactions_get.rb +0 -30
  62. data/lib/pact/consumer/mock_service/mock_service_administration_endpoint.rb +0 -31
  63. data/lib/pact/consumer/mock_service/pact_post.rb +0 -33
  64. data/lib/pact/consumer/mock_service/rack_request_helper.rb +0 -51
  65. data/lib/pact/consumer/mock_service/verification_get.rb +0 -68
  66. data/lib/pact/consumer/mock_service.rb +0 -2
  67. data/lib/pact/consumer/mock_service_client.rb +0 -65
  68. data/lib/pact/consumer/mock_service_interaction_expectation.rb +0 -37
  69. data/lib/pact/consumer/request.rb +0 -27
  70. data/lib/pact/consumer/server.rb +0 -90
  71. data/lib/pact/consumer_contract/consumer_contract.rb +0 -115
  72. data/lib/pact/consumer_contract/consumer_contract_writer.rb +0 -84
  73. data/lib/pact/consumer_contract/file_name.rb +0 -19
  74. data/lib/pact/consumer_contract/headers.rb +0 -51
  75. data/lib/pact/consumer_contract/interaction.rb +0 -67
  76. data/lib/pact/consumer_contract/pact_file.rb +0 -24
  77. data/lib/pact/consumer_contract/request.rb +0 -73
  78. data/lib/pact/consumer_contract/service_consumer.rb +0 -28
  79. data/lib/pact/consumer_contract/service_provider.rb +0 -28
  80. data/lib/pact/consumer_contract.rb +0 -1
  81. data/lib/pact/logging.rb +0 -14
  82. data/lib/pact/matchers/actual_type.rb +0 -16
  83. data/lib/pact/matchers/base_difference.rb +0 -37
  84. data/lib/pact/matchers/differ.rb +0 -153
  85. data/lib/pact/matchers/difference.rb +0 -13
  86. data/lib/pact/matchers/difference_indicator.rb +0 -26
  87. data/lib/pact/matchers/embedded_diff_formatter.rb +0 -62
  88. data/lib/pact/matchers/expected_type.rb +0 -35
  89. data/lib/pact/matchers/index_not_found.rb +0 -15
  90. data/lib/pact/matchers/list_diff_formatter.rb +0 -101
  91. data/lib/pact/matchers/matchers.rb +0 -139
  92. data/lib/pact/matchers/no_diff_indicator.rb +0 -18
  93. data/lib/pact/matchers/regexp_difference.rb +0 -13
  94. data/lib/pact/matchers/type_difference.rb +0 -16
  95. data/lib/pact/matchers/unexpected_index.rb +0 -11
  96. data/lib/pact/matchers/unexpected_key.rb +0 -11
  97. data/lib/pact/matchers/unix_diff_formatter.rb +0 -114
  98. data/lib/pact/matchers.rb +0 -1
  99. data/lib/pact/reification.rb +0 -28
  100. data/lib/pact/rspec.rb +0 -53
  101. data/lib/pact/shared/active_support_support.rb +0 -51
  102. data/lib/pact/shared/dsl.rb +0 -76
  103. data/lib/pact/shared/jruby_support.rb +0 -18
  104. data/lib/pact/shared/json_differ.rb +0 -15
  105. data/lib/pact/shared/key_not_found.rb +0 -15
  106. data/lib/pact/shared/null_expectation.rb +0 -31
  107. data/lib/pact/shared/request.rb +0 -80
  108. data/lib/pact/shared/text_differ.rb +0 -14
  109. data/lib/pact/something_like.rb +0 -49
  110. data/lib/pact/symbolize_keys.rb +0 -12
  111. data/lib/pact/term.rb +0 -85
  112. data/scratchpad.rb +0 -52
  113. data/spec/features/consumption_spec.rb +0 -114
  114. data/spec/features/production_spec.rb +0 -155
  115. data/spec/features/provider_states/zebras.rb +0 -28
  116. data/spec/integration/consumer_spec.rb +0 -212
  117. data/spec/integration/pact/consumer_configuration_spec.rb +0 -66
  118. data/spec/integration/pact/provider_configuration_spec.rb +0 -25
  119. data/spec/lib/pact/cli_spec.rb +0 -47
  120. data/spec/lib/pact/configuration_spec.rb +0 -297
  121. data/spec/lib/pact/consumer/app_manager_spec.rb +0 -41
  122. data/spec/lib/pact/consumer/configuration_spec.rb +0 -57
  123. data/spec/lib/pact/consumer/consumer_contract_builder_spec.rb +0 -69
  124. data/spec/lib/pact/consumer/interaction_builder_spec.rb +0 -91
  125. data/spec/lib/pact/consumer/interactions_spec.rb +0 -64
  126. data/spec/lib/pact/consumer/mock_service/app_spec.rb +0 -52
  127. data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +0 -78
  128. data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +0 -70
  129. data/spec/lib/pact/consumer/mock_service/interaction_replay_spec.rb +0 -12
  130. data/spec/lib/pact/consumer/mock_service/rack_request_helper_spec.rb +0 -88
  131. data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +0 -142
  132. data/spec/lib/pact/consumer/mock_service_client_spec.rb +0 -88
  133. data/spec/lib/pact/consumer/mock_service_interaction_expectation_spec.rb +0 -54
  134. data/spec/lib/pact/consumer/request_spec.rb +0 -24
  135. data/spec/lib/pact/consumer/service_consumer_spec.rb +0 -11
  136. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  137. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -180
  138. data/spec/lib/pact/consumer_contract/consumer_contract_writer_spec.rb +0 -111
  139. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  140. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -107
  141. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -329
  142. data/spec/lib/pact/doc/generator_spec.rb +0 -84
  143. data/spec/lib/pact/doc/interaction_view_model_spec.rb +0 -132
  144. data/spec/lib/pact/doc/markdown/consumer_contract_renderer_spec.rb +0 -29
  145. data/spec/lib/pact/doc/markdown/index_renderer_spec.rb +0 -29
  146. data/spec/lib/pact/matchers/differ_spec.rb +0 -214
  147. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  148. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  149. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  150. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -114
  151. data/spec/lib/pact/matchers/matchers_spec.rb +0 -500
  152. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  153. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -34
  154. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  155. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  156. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -216
  157. data/spec/lib/pact/provider/configuration/configuration_extension_spec.rb +0 -30
  158. data/spec/lib/pact/provider/configuration/pact_verification_spec.rb +0 -43
  159. data/spec/lib/pact/provider/configuration/service_provider_config_spec.rb +0 -21
  160. data/spec/lib/pact/provider/configuration/service_provider_dsl_spec.rb +0 -108
  161. data/spec/lib/pact/provider/configuration_spec.rb +0 -50
  162. data/spec/lib/pact/provider/matchers/messages_spec.rb +0 -116
  163. data/spec/lib/pact/provider/pact_helper_locator_spec.rb +0 -54
  164. data/spec/lib/pact/provider/print_missing_provider_states_spec.rb +0 -19
  165. data/spec/lib/pact/provider/request_spec.rb +0 -78
  166. data/spec/lib/pact/provider/rspec/formatter_rspec_2_spec.rb +0 -68
  167. data/spec/lib/pact/provider/rspec/formatter_rspec_3_spec.rb +0 -72
  168. data/spec/lib/pact/provider/rspec_spec.rb +0 -55
  169. data/spec/lib/pact/provider/state/provider_state_manager_spec.rb +0 -89
  170. data/spec/lib/pact/provider/state/provider_state_proxy_spec.rb +0 -80
  171. data/spec/lib/pact/provider/state/provider_state_spec.rb +0 -213
  172. data/spec/lib/pact/provider/world_spec.rb +0 -41
  173. data/spec/lib/pact/reification_spec.rb +0 -67
  174. data/spec/lib/pact/shared/dsl_spec.rb +0 -86
  175. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  176. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  177. data/spec/lib/pact/shared/request_spec.rb +0 -111
  178. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  179. data/spec/lib/pact/something_like_spec.rb +0 -21
  180. data/spec/lib/pact/tasks/task_helper_spec.rb +0 -74
  181. data/spec/lib/pact/tasks/verification_task_spec.rb +0 -75
  182. data/spec/lib/pact/term_spec.rb +0 -89
  183. data/spec/pact_specification/compliance-1.0.0.rb +0 -47
  184. data/spec/spec_helper.rb +0 -22
  185. data/spec/standalone/consumer_fail_test.rb +0 -55
  186. data/spec/standalone/consumer_pass_test.rb +0 -51
  187. data/spec/support/a_consumer-a_producer.json +0 -32
  188. data/spec/support/a_consumer-a_provider.json +0 -32
  189. data/spec/support/active_support_if_configured.rb +0 -6
  190. data/spec/support/app_for_config_ru.rb +0 -4
  191. data/spec/support/consumer_contract_template.json +0 -24
  192. data/spec/support/dsl_spec_support.rb +0 -7
  193. data/spec/support/factories.rb +0 -82
  194. data/spec/support/generated_index.md +0 -4
  195. data/spec/support/generated_markdown.md +0 -55
  196. data/spec/support/interaction_view_model.json +0 -63
  197. data/spec/support/interaction_view_model_with_terms.json +0 -50
  198. data/spec/support/markdown_pact.json +0 -48
  199. data/spec/support/missing_provider_states_output.txt +0 -25
  200. data/spec/support/options.json +0 -21
  201. data/spec/support/options_app.rb +0 -15
  202. data/spec/support/pact_helper.rb +0 -57
  203. data/spec/support/shared_examples_for_request.rb +0 -94
  204. data/spec/support/spec_support.rb +0 -20
  205. data/spec/support/stubbing.json +0 -22
  206. data/spec/support/stubbing_using_allow.rb +0 -29
  207. data/spec/support/term.json +0 -48
  208. data/spec/support/test_app_fail.json +0 -61
  209. data/spec/support/test_app_pass.json +0 -38
  210. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  211. data/tasks/pact-test.rake +0 -109
  212. data/tasks/spec.rake +0 -8
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pact
4
- describe Reification do
5
-
6
- let(:response_spec) do
7
- {
8
- woot: /x/,
9
- britney: 'britney',
10
- nested: { foo: /bar/, baz: 'qux' },
11
- my_term: Term.new(generate: 'wiffle', matcher: /^wif/),
12
- array: ['first', /second/]
13
- }
14
- end
15
-
16
- describe "from term" do
17
-
18
- subject { Reification.from_term(response_spec) }
19
-
20
- it "converts regexes into real data" do
21
- expect(subject[:woot]).to eql 'x'
22
- end
23
-
24
- it "converts terms into real data" do
25
- expect(subject[:my_term]).to eql 'wiffle'
26
- end
27
-
28
- it "passes strings through" do
29
- expect(subject[:britney]).to eql 'britney'
30
- end
31
-
32
- it "handles nested hashes" do
33
- expect(subject[:nested]).to eql({ foo: 'bar', baz: 'qux' })
34
- end
35
-
36
- it "handles arrays" do
37
- expect(subject[:array]).to eql ['first', 'second']
38
- end
39
-
40
- end
41
-
42
- context "when reifying a Request" do
43
-
44
- let(:request){ Pact::Request::Expected.from_hash(method: 'get', path: '/', body: Pact::Term.new(generate: "sunny", matcher: /sun/))}
45
-
46
- subject { Reification.from_term(request) }
47
-
48
- it "turns it into a hash before reifying it" do
49
- expect(subject[:body]).to eq("sunny")
50
- end
51
-
52
- end
53
-
54
- context "when SomethingLike" do
55
-
56
- let(:request) { Pact::SomethingLike.new({a: 'String'})}
57
-
58
- subject { Reification.from_term(request)}
59
-
60
- it "returns the contents of the SomethingLike" do
61
- expect(subject).to eq({a: 'String'})
62
- end
63
-
64
- end
65
-
66
- end
67
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/dsl'
3
- require 'support/dsl_spec_support'
4
-
5
- module Pact
6
- describe DSL do
7
-
8
- class TestDSL
9
- extend DSL
10
- attr_accessor :thing, :blah, :global, :the_block, :another_block, :finalized
11
-
12
- dsl do
13
- def with_thing thing
14
- self.thing = thing
15
- end
16
- def with_blah blah
17
- self.blah = blah
18
- end
19
- def with_global global
20
- self.global = global
21
- end
22
-
23
- def with_block &the_block
24
- self.the_block = the_block
25
- end
26
-
27
- def with_another_block &the_block
28
- self.another_block = the_block
29
- end
30
-
31
- end
32
-
33
- def finalize
34
- @finalized = true
35
- end
36
- end
37
-
38
- describe "build" do
39
- before do
40
- def my_local_method
41
- 'LA LA LA'
42
- end
43
-
44
- my_local_var = 123
45
-
46
- local_app = "I'm a local app"
47
-
48
- @test = TestDSL.build do
49
- with_thing my_local_method
50
- with_blah my_local_var
51
- with_global global_method
52
- with_block do
53
- global_app
54
- end
55
- with_another_block do
56
- local_app
57
- end
58
- end
59
- end
60
-
61
- it "supports using a local variable" do
62
- expect(@test.blah).to eq 123
63
- end
64
-
65
- it "supports using a local method" do
66
- expect(@test.thing).to eq 'LA LA LA'
67
- end
68
-
69
- it "supports using global methods from other files" do
70
- expect(@test.global).to eq "I'm global"
71
- end
72
-
73
- it "supports using a local method to provide the app" do
74
- expect(@test.another_block.call).to eq("I'm a local app")
75
- end
76
-
77
- it "should support using a global method to provide the app but it doesn't" do
78
- expect(@test.the_block.call).to eq("I'm a global app")
79
- end
80
-
81
- it "calls finalize" do
82
- expect(@test.finalized).to be true
83
- end
84
- end
85
- end
86
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/json_differ'
3
-
4
- module Pact
5
- describe JsonDiffer do
6
-
7
- describe ".call" do
8
-
9
- let(:expected) { {'a' => 'b'} }
10
-
11
- subject { JsonDiffer.call(expected, actual) }
12
-
13
- context "when the actual is valid JSON" do
14
-
15
- let(:actual) { {'a' => 'c'} }
16
- let(:difference) { {'a' => Pact::Matchers::Difference.new('b', 'c')} }
17
-
18
- context "when the actual does not equal the expected" do
19
- it "parses the JSON and returns a diff" do
20
- expect(subject).to eq(difference)
21
- end
22
- end
23
-
24
- context "when the actual equals the expected" do
25
- let(:actual) { expected }
26
- it "parses the JSON and returns an empty diff" do
27
- expect(subject.any?).to be false
28
- end
29
- end
30
-
31
- end
32
-
33
- end
34
-
35
- end
36
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/key_not_found'
3
-
4
- module Pact
5
- describe KeyNotFound 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
- end
@@ -1,111 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/request'
3
- require 'pact/shared/key_not_found'
4
-
5
- module Pact
6
-
7
- module Request
8
-
9
- describe Base do
10
-
11
- class TestRequest < Base
12
-
13
- def self.key_not_found
14
- Pact::KeyNotFound.new
15
- end
16
-
17
- end
18
-
19
- subject { TestRequest.new("get", "/", {some: "things"}, {some: "things"} , "some=things") }
20
-
21
- describe "#to_json" do
22
- it "renders the keys in a sensible order" do
23
- expect(subject.to_json).to match(/method.*path.*query.*headers.*body/)
24
- end
25
- end
26
-
27
- describe "#full_path" do
28
-
29
- subject { TestRequest.new("get", "/something", {}, {some: "things"} , query).full_path }
30
-
31
- context "with a query that is a Pact::Term" do
32
- let(:query) { Pact::Term.new(generate: "some=things", matcher: /some/) }
33
- it "reifies and appends the query" do
34
- expect(subject).to eq("/something?some=things")
35
- end
36
- end
37
-
38
- context "with a query that is a string" do
39
- let(:query) { "some=things" }
40
- it "appends the query" do
41
- expect(subject).to eq("/something?some=things")
42
- end
43
- end
44
-
45
- context "with an empty query" do
46
- let(:query) { "" }
47
- it "does include a query" do
48
- expect(subject).to eq("/something")
49
- end
50
- end
51
-
52
- context "with a nil query" do
53
- let(:query) { nil }
54
- it "does not include a query" do
55
- expect(subject).to eq("/something")
56
- end
57
- end
58
- end
59
-
60
- describe "#method_and_path" do
61
- context "with an empty path" do
62
- subject { TestRequest.new("get", "", {}, {} , "").method_and_path }
63
-
64
- it "includes a slash" do
65
- expect(subject).to eq("GET /")
66
- end
67
- end
68
-
69
- context "with a path" do
70
- subject { TestRequest.new("get", "/something", {}, {} , "").method_and_path }
71
-
72
- it "includes the path" do
73
- expect(subject).to eq("GET /something")
74
- end
75
- end
76
-
77
- context "with a query" do
78
- subject { TestRequest.new("get", "/something", {}, {} , "test=query").method_and_path }
79
-
80
- it "includes the query" do
81
- expect(subject).to eq("GET /something?test=query")
82
- end
83
- end
84
- end
85
-
86
- describe "#content_type" do
87
-
88
- subject { TestRequest.new("get", "/something", headers, {} , "") }
89
- context "when there are no expected headers" do
90
- let(:headers) { Pact::KeyNotFound.new }
91
- it "returns nil" do
92
- expect(subject.send(:content_type)).to be nil
93
- end
94
- end
95
- context "when there is no Content-Type header" do
96
- let(:headers) { {} }
97
- it "returns the content-type" do
98
- expect(subject.send(:content_type)).to be nil
99
- end
100
- end
101
- context "when there is a content-type header (" do
102
- let(:headers) { {'content-type' => 'blah'} }
103
- it "returns the content-type" do
104
- expect(subject.send(:content_type)).to eq 'blah'
105
- end
106
- end
107
- end
108
-
109
- end
110
- end
111
- end
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/shared/text_differ'
3
-
4
- module Pact
5
- describe TextDiffer do
6
-
7
- describe ".call" do
8
-
9
- subject { TextDiffer.call expected, actual }
10
-
11
- let(:expected) { "This is the string you are looking for" }
12
-
13
- context "when the expected and actual are both strings" do
14
-
15
- context "when they equal each other" do
16
- let(:actual) { "This is the string you are looking for" }
17
-
18
- it "returns an empty diff" do
19
- expect(subject.any?).to be false
20
- end
21
- end
22
-
23
- context "when they don't equal each other" do
24
- let(:actual) { "This is not the string you are looking for" }
25
-
26
- it "returns the diff" do
27
- expect(subject).to eq Pact::Matchers::Difference.new(expected, actual)
28
- end
29
- end
30
- end
31
-
32
- context "when the actual is not a String" do
33
- let(:actual) { {some: 'hash'} }
34
- let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
35
- it "returns the diff" do
36
- expect(subject)
37
- end
38
- end
39
-
40
- context "when the expected and actual are both objects" do
41
- let(:actual) { {some: 'hash', blah: 'blah'} }
42
- let(:expected) { {some: 'hash'} }
43
- let(:difference) { Pact::Matchers::Difference.new(expected, actual)}
44
-
45
- it "returns the diff using the JSON matching logic, allowing extra keys. But should it really if the expected Content-Type isn't actually JSON?" do
46
- expect(subject)
47
- end
48
-
49
- it "potentially should treat both expected and actual as Strings"
50
- end
51
-
52
- end
53
- end
54
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pact
4
- describe SomethingLike do
5
- describe 'json_create' do
6
- let(:json) do
7
- '
8
- {
9
- "json_class": "Pact::SomethingLike",
10
- "contents" : { "thing" : "blah" }
11
- }
12
- '
13
- end
14
- subject { SomethingLike.json_create(JSON.parse(json)) }
15
- it "creates a SomethingLike object from json" do
16
- expect(subject).to eq(SomethingLike.new({"thing" => "blah"}))
17
- end
18
- end
19
- end
20
-
21
- end
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/tasks/task_helper'
3
- require 'rake/file_utils'
4
-
5
- module Pact
6
- describe TaskHelper do
7
-
8
-
9
- describe ".execute_pact_verify" do
10
- let(:ruby_path) { "/path/to/ruby" }
11
- let(:pact_uri) { "/pact/uri" }
12
- let(:default_pact_helper_path) { "/pact/helper/path.rb" }
13
-
14
- before do
15
- stub_const("FileUtils::RUBY", ruby_path)
16
- allow(Pact::Provider::PactHelperLocater).to receive(:pact_helper_path).and_return(default_pact_helper_path)
17
- end
18
-
19
- context "with no pact_helper or pact URI" do
20
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{default_pact_helper_path}" }
21
- it "executes the command" do
22
- expect(TaskHelper).to receive(:execute_cmd).with(command)
23
- TaskHelper.execute_pact_verify
24
- end
25
- end
26
-
27
- context "with a pact URI" do
28
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{default_pact_helper_path} -p #{pact_uri}" }
29
- it "executes the command" do
30
- expect(TaskHelper).to receive(:execute_cmd).with(command)
31
- TaskHelper.execute_pact_verify(pact_uri)
32
- end
33
- end
34
-
35
- context "with a pact URI and a pact_helper" do
36
- let(:custom_pact_helper_path) { '/custom/pact_helper.rb' }
37
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{custom_pact_helper_path} -p #{pact_uri}" }
38
- it "executes the command" do
39
- expect(TaskHelper).to receive(:execute_cmd).with(command)
40
- TaskHelper.execute_pact_verify(pact_uri, custom_pact_helper_path)
41
- end
42
- end
43
-
44
- context "with a pact_helper with no .rb on the end" do
45
- let(:custom_pact_helper_path) { '/custom/pact_helper' }
46
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{custom_pact_helper_path}.rb -p #{pact_uri}" }
47
- it "executes the command" do
48
- expect(TaskHelper).to receive(:execute_cmd).with(command)
49
- TaskHelper.execute_pact_verify(pact_uri, custom_pact_helper_path)
50
- end
51
- end
52
-
53
- context "with a pact URI and a nil pact_helper" do
54
- let(:command) { "SPEC_OPTS='' #{ruby_path} -S pact verify -h #{default_pact_helper_path} -p #{pact_uri}" }
55
- it "executes the command" do
56
- expect(TaskHelper).to receive(:execute_cmd).with(command)
57
- TaskHelper.execute_pact_verify(pact_uri, nil)
58
- end
59
- end
60
-
61
- context "with rspec_opts" do
62
- it "includes the rspec_opts as SPEC_OPTS in the command" do
63
- expect(TaskHelper).to receive(:execute_cmd) do | command |
64
- expect(command).to start_with("SPEC_OPTS=--reporter\\ SomeReporter #{ruby_path}")
65
- end
66
- TaskHelper.execute_pact_verify(pact_uri, nil, "--reporter SomeReporter")
67
- end
68
- end
69
-
70
- end
71
-
72
-
73
- end
74
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/tasks/verification_task'
3
-
4
- module Pact
5
- describe VerificationTask do
6
- before :all do
7
- @pact_helper = '/custom/path/pact_helper .rb'
8
- @pact_uri = 'http://example.org/pact.json'
9
- @task_name = 'pact:verify:pact_rake_spec'
10
- @task_name_with_explict_pact_helper = 'pact:verify:pact_rake_spec_with_explict_pact_helper'
11
- @consumer = 'some-consumer'
12
- @criteria = {:description => /wiffle/}
13
-
14
- VerificationTask.new(:pact_rake_spec_with_explict_pact_helper) do | pact |
15
- pact.uri @pact_uri, pact_helper: @pact_helper
16
- end
17
-
18
- VerificationTask.new(:pact_rake_spec) do | pact |
19
- pact.uri @pact_uri
20
- end
21
- end
22
-
23
- before do
24
- allow(Pact::TaskHelper).to receive(:execute_pact_verify).and_return(0)
25
- end
26
-
27
- let(:exit_code) {0}
28
-
29
-
30
- describe '.initialize' do
31
- context 'with an explict pact_helper' do
32
- it 'creates the tasks' do
33
- expect(Rake::Task.tasks).to include_task @task_name
34
- end
35
- end
36
- context 'with no explict pact_helper' do
37
- it 'creates the tasks' do
38
- expect(Rake::Task.tasks).to include_task @task_name_with_explict_pact_helper
39
- end
40
- end
41
- end
42
-
43
- describe 'execute' do
44
-
45
- context "with no explicit pact_helper" do
46
- it 'verifies the pacts using the TaskHelper' do
47
- expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, nil, nil)
48
- Rake::Task[@task_name].execute
49
- end
50
- end
51
-
52
- context "with an explict pact_helper" do
53
- let(:verification_config) { [ uri: @pact_uri, pact_helper: @pact_helper] }
54
- it 'verifies the pacts using the TaskHelper' do
55
- expect(Pact::TaskHelper).to receive(:execute_pact_verify).with(@pact_uri, @pact_helper, nil)
56
- Rake::Task[@task_name_with_explict_pact_helper].execute
57
- end
58
- end
59
-
60
- context 'when all specs pass' do
61
-
62
- it 'does not raise an exception' do
63
- Rake::Task[@task_name].execute
64
- end
65
- end
66
-
67
- end
68
- end
69
- end
70
-
71
- RSpec::Matchers.define :include_task do |expected|
72
- match do |actual|
73
- actual.any? { |task| task.name == expected }
74
- end
75
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Pact
4
- describe Term do
5
-
6
- describe 'initialize' do
7
- let(:matcher) { /e/ }
8
- let(:generate) { 'apple'}
9
- subject { Term.new(generate: generate, matcher: matcher) }
10
- context "when a matcher and generate are specified" do
11
- context "when the matcher matches the generated value" do
12
- it 'does not raise an exception' do
13
- subject
14
- end
15
- end
16
-
17
- context "when the matcher does not match the generated value" do
18
- let(:generate) { 'banana' }
19
- it 'raises an exception' do
20
- expect { subject }.to raise_error /does not match/
21
- end
22
- end
23
- end
24
- context 'when a matcher is not specified' do
25
- let(:matcher) { nil }
26
- it 'raises an exception' do
27
- expect { subject }.to raise_error /Please specify a matcher/
28
- end
29
- end
30
- context 'when a generate is not specified' do
31
- let(:generate) { nil }
32
- it 'raises an exception' do
33
- expect { subject }.to raise_error /Please specify a value/
34
- end
35
- end
36
- end
37
-
38
- describe "equality" do
39
- context "when the matcher and generate attrs are the same" do
40
- let(:this) { Term.new(generate: 'A', matcher: /A/) }
41
- let(:that) { Term.new(generate: 'A', matcher: /A/) }
42
-
43
- it "is equal" do
44
- expect(this).to eq that
45
- end
46
- end
47
-
48
- context "when the generate attrs are different" do
49
- let(:this) { Term.new(generate: 'A', matcher: /.*/) }
50
- let(:that) { Term.new(generate: 'B', matcher: /.*/) }
51
-
52
- it "is not equal" do
53
- expect(this).to_not eq that
54
- end
55
- end
56
-
57
- context "when the matcher attrs are different" do
58
- let(:this) { Term.new(matcher: /A/, generate: 'AB') }
59
- let(:that) { Term.new(matcher: /B/, generate: 'AB') }
60
-
61
- it "is not equal" do
62
- expect(this).to_not eq that
63
- end
64
- end
65
- end
66
-
67
- describe 'empty?' do
68
-
69
- subject { Term.new(generate: 'some', matcher: /some/) }
70
-
71
- it 'should return false' do
72
- expect(subject).to_not be_empty
73
- end
74
-
75
- end
76
-
77
- describe 'unpack_regexps' do
78
- let(:term) { Term.new(generate: 'some', matcher: /s/) }
79
- let(:body) { [{a: [{b: term}], c:term, d: 1, e: 'blah'}] }
80
- let(:expected) { [{:a=>[{:b=>/s/}], :c=>/s/, :d=>1, :e=>"blah"}] }
81
-
82
- it "returns a structure with the Pact::Terms replaced by their regexps" do
83
- expect(Term.unpack_regexps(body)).to eq expected
84
- end
85
-
86
- end
87
-
88
- end
89
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
- require 'pact/consumer/request'
3
- require 'pact/consumer_contract/request'
4
-
5
- PACT_SPEC_DIR = "../pact-specification/testcases"
6
- REQUEST_TEST_CASE_FOLDERS = Dir.glob("#{PACT_SPEC_DIR}/request/**")
7
- REQUEST_TEST_CASE_FILES = Dir.glob("#{PACT_SPEC_DIR}/request/**/*.json")
8
-
9
- TEST_DESCRIPTIONS = {true => "matches", false => "does not match"}
10
-
11
- describe "Pact gem complicance with Pact Specification 1.0.0" do
12
-
13
- directories = Dir.glob("#{PACT_SPEC_DIR}/*")
14
-
15
- directories.each do | dir_name |
16
-
17
- describe File.basename(dir_name) do
18
-
19
- sub_directories = Dir.glob("#{dir_name}/*")
20
-
21
- sub_directories.each do | sub_dir_name |
22
-
23
- context File.basename(sub_dir_name) do
24
- testcases = Dir.glob("#{sub_dir_name}/**/*.json")
25
-
26
- testcases.each do | file_name |
27
-
28
- context File.basename(file_name).chomp(".json") do
29
-
30
- file_content = JSON.parse(File.read(file_name))
31
- expected = Pact::Request::Expected.from_hash(file_content["expected"])
32
- actual = Pact::Consumer::Request::Actual.from_hash(file_content["actual"])
33
- expected_result = file_content.fetch("match")
34
- comment = file_content["comment"]
35
-
36
- it "#{TEST_DESCRIPTIONS[expected_result]} - #{comment}" do
37
- expect(expected.matches?(actual)).to eq expected_result
38
- end
39
-
40
- end
41
-
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end