pact-mock_service 0.2.2 → 0.2.3.pre.rc1

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/lib/pact/consumer/app_manager.rb +5 -1
  4. data/lib/pact/consumer/interactions_filter.rb +1 -17
  5. data/lib/pact/consumer/mock_service/actual_interactions.rb +34 -0
  6. data/lib/pact/consumer/mock_service/app.rb +21 -18
  7. data/lib/pact/consumer/mock_service/candidate_interactions.rb +13 -0
  8. data/lib/pact/consumer/mock_service/expected_interactions.rb +17 -0
  9. data/lib/pact/consumer/mock_service/interaction_delete.rb +11 -5
  10. data/lib/pact/consumer/mock_service/interaction_post.rb +69 -6
  11. data/lib/pact/consumer/mock_service/interaction_replay.rb +77 -57
  12. data/lib/pact/consumer/mock_service/log_get.rb +1 -1
  13. data/lib/pact/consumer/mock_service/missing_interactions_get.rb +7 -4
  14. data/lib/pact/consumer/mock_service/pact_post.rb +6 -4
  15. data/lib/pact/consumer/mock_service/rack_request_helper.rb +1 -1
  16. data/lib/pact/consumer/mock_service/verification.rb +46 -0
  17. data/lib/pact/consumer/mock_service/verification_get.rb +17 -12
  18. data/lib/pact/consumer/mock_service/verified_interactions.rb +18 -0
  19. data/lib/pact/consumer/mock_service_client.rb +4 -4
  20. data/lib/pact/consumer/server.rb +2 -0
  21. data/lib/pact/consumer_contract/consumer_contract_writer.rb +2 -0
  22. data/lib/pact/mock_service/cli.rb +21 -14
  23. data/lib/pact/mock_service/version.rb +1 -1
  24. metadata +10 -124
  25. data/.gitignore +0 -30
  26. data/.rspec +0 -3
  27. data/.travis.yml +0 -8
  28. data/Rakefile +0 -6
  29. data/lib/pact/consumer/mock_service/interaction_list.rb +0 -76
  30. data/pact-mock-service.gemspec +0 -39
  31. data/spec/features/mock_multiple_responses_spec.rb +0 -120
  32. data/spec/features/mock_response_spec.rb +0 -71
  33. data/spec/lib/pact/consumer/app_manager_spec.rb +0 -42
  34. data/spec/lib/pact/consumer/mock_service/app_spec.rb +0 -52
  35. data/spec/lib/pact/consumer/mock_service/interaction_list_spec.rb +0 -78
  36. data/spec/lib/pact/consumer/mock_service/interaction_mismatch_spec.rb +0 -70
  37. data/spec/lib/pact/consumer/mock_service/interaction_replay_spec.rb +0 -12
  38. data/spec/lib/pact/consumer/mock_service/rack_request_helper_spec.rb +0 -88
  39. data/spec/lib/pact/consumer/mock_service/verification_get_spec.rb +0 -142
  40. data/spec/lib/pact/consumer/mock_service_client_spec.rb +0 -88
  41. data/spec/lib/pact/consumer/service_consumer_spec.rb +0 -11
  42. data/spec/lib/pact/consumer_contract/consumer_contract_writer_spec.rb +0 -128
  43. data/spec/lib/pact/consumer_contract/request_decorator_body_spec.rb +0 -77
  44. data/spec/lib/pact/consumer_contract/request_decorator_headers_spec.rb +0 -69
  45. data/spec/lib/pact/consumer_contract/request_decorator_path_spec.rb +0 -42
  46. data/spec/lib/pact/consumer_contract/request_decorator_query_spec.rb +0 -74
  47. data/spec/lib/pact/consumer_contract/request_decorator_spec.rb +0 -41
  48. data/spec/lib/pact/consumer_contract/response_decorator_spec.rb +0 -10
  49. data/spec/lib/pact/mock_service/interaction_decorator_spec.rb +0 -74
  50. data/spec/lib/pact/mock_service/request_decorator_spec.rb +0 -76
  51. data/spec/lib/pact/mock_service/response_decorator_spec.rb +0 -12
  52. data/spec/spec_helper.rb +0 -16
  53. data/spec/support/a_consumer-a_producer.json +0 -32
  54. data/spec/support/a_consumer-a_provider.json +0 -32
  55. data/spec/support/active_support_if_configured.rb +0 -6
  56. data/spec/support/app_for_config_ru.rb +0 -4
  57. data/spec/support/case-insensitive-response-header-matching.json +0 -21
  58. data/spec/support/case-insensitive-response-header-matching.rb +0 -15
  59. data/spec/support/consumer_contract_template.json +0 -24
  60. data/spec/support/dsl_spec_support.rb +0 -7
  61. data/spec/support/factories.rb +0 -82
  62. data/spec/support/generated_index.md +0 -4
  63. data/spec/support/generated_markdown.md +0 -55
  64. data/spec/support/interaction_view_model.json +0 -63
  65. data/spec/support/interaction_view_model_with_terms.json +0 -50
  66. data/spec/support/markdown_pact.json +0 -48
  67. data/spec/support/missing_provider_states_output.txt +0 -25
  68. data/spec/support/options.json +0 -21
  69. data/spec/support/options_app.rb +0 -15
  70. data/spec/support/pact_helper.rb +0 -57
  71. data/spec/support/shared_examples_for_request.rb +0 -94
  72. data/spec/support/shared_examples_for_response_decorator.rb +0 -25
  73. data/spec/support/spec_support.rb +0 -20
  74. data/spec/support/stubbing.json +0 -22
  75. data/spec/support/stubbing_using_allow.rb +0 -29
  76. data/spec/support/term.json +0 -48
  77. data/spec/support/test_app_fail.json +0 -61
  78. data/spec/support/test_app_pass.json +0 -38
  79. data/spec/support/test_app_with_right_content_type_differ.json +0 -23
  80. data/tasks/spec.rake +0 -6
@@ -1,94 +0,0 @@
1
- shared_examples "a request" do
2
-
3
- describe 'matching' do
4
- let(:expected) do
5
- Pact::Request::Expected.from_hash(
6
- {'method' => 'get', 'path' => 'path', 'query' => /b/}
7
- )
8
- end
9
-
10
- let(:actual) do
11
- Pact::Consumer::Request::Actual.from_hash({'method' => 'get', 'path' => 'path', 'query' => 'blah', 'headers' => {}, 'body' => ''})
12
- end
13
-
14
- it "should match" do
15
- expect(expected.difference(actual)).to eq({})
16
- end
17
- end
18
-
19
- describe 'full_path' do
20
- context "with empty path" do
21
- subject { described_class.from_hash({:path => '', :method => 'get', :query => '', :headers => {}}) }
22
- it "returns the full path"do
23
- expect(subject.full_path).to eq "/"
24
- end
25
- end
26
- context "with a path" do
27
- subject { described_class.from_hash({:path => '/path', :method => 'get', :query => '', :headers => {}}) }
28
- it "returns the full path"do
29
- expect(subject.full_path).to eq "/path"
30
- end
31
- end
32
- context "with a path and query" do
33
- subject { described_class.from_hash({:path => '/path', :method => 'get', :query => "something", :headers => {}}) }
34
- it "returns the full path"do
35
- expect(subject.full_path).to eq "/path?something"
36
- end
37
- end
38
- context "with a path and a query that is a Term" do
39
- subject { described_class.from_hash({:path => '/path', :method => 'get', :headers => {}, :query => Pact::Term.new(generate: 'a', matcher: /a/)}) }
40
- it "returns the full path with reified path" do
41
- expect(subject.full_path).to eq "/path?a"
42
- end
43
- end
44
- end
45
-
46
- describe "building from a hash" do
47
-
48
- let(:raw_request) do
49
- {
50
- 'method' => 'get',
51
- 'path' => '/mallory',
52
- 'query' => 'query',
53
- 'headers' => {
54
- 'Content-Type' => 'application/json'
55
- },
56
- 'body' => 'hello mallory'
57
- }
58
- end
59
-
60
- subject { described_class.from_hash(raw_request) }
61
-
62
- it "extracts the method" do
63
- expect(subject.method).to eq 'get'
64
- end
65
-
66
- it "extracts the path" do
67
- expect(subject.path).to eq '/mallory'
68
- end
69
-
70
- it "extracts the body" do
71
- expect(subject.body).to eq 'hello mallory'
72
- end
73
-
74
- it "extracts the query" do
75
- expect(subject.query).to eq 'query'
76
- end
77
-
78
- it "blows up if method is absent" do
79
- raw_request.delete 'method'
80
- expect { described_class.from_hash(raw_request) }.to raise_error
81
- end
82
-
83
- it "blows up if path is absent" do
84
- raw_request.delete 'path'
85
- expect { described_class.from_hash(raw_request) }.to raise_error
86
- end
87
-
88
- it "does not blow up if body is missing" do
89
- raw_request.delete 'body'
90
- expect { described_class.from_hash(raw_request) }.to_not raise_error
91
- end
92
-
93
- end
94
- end
@@ -1,25 +0,0 @@
1
- require 'pact/consumer_contract/response'
2
-
3
- shared_examples_for "request decorator to_json" do
4
-
5
- describe "#to_json" do
6
-
7
- let(:response) { Pact::Response.new(status: 200, body: body) }
8
- let(:body) { { baz: /qux/, wiffle: Pact::Term.new(generate: 'wiffle', matcher: /iff/) } }
9
-
10
- let(:decorator) { described_class.new(response) }
11
-
12
- subject { JSON.load decorator.to_json }
13
-
14
- it "serialises regexes" do
15
- expect(subject['body']['baz']).to eql /qux/
16
- end
17
-
18
- it "serialises terms" do
19
- parsed_term = subject['body']['wiffle']
20
- expect(parsed_term.matcher).to eql /iff/
21
- expect(parsed_term.generate).to eql 'wiffle'
22
- end
23
-
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- require 'pact/rspec'
2
-
3
- module Pact
4
- module SpecSupport
5
-
6
- extend self
7
-
8
- def remove_ansicolor string
9
- string.gsub(/\e\[(\d+)m/, '')
10
- end
11
-
12
- Pact::RSpec.with_rspec_2 do
13
-
14
- def instance_double *args
15
- double(*args)
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,22 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "Consumer"
4
- },
5
- "provider": {
6
- "name": "Provider"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request",
11
- "request": {
12
- "method": "get",
13
- "path": "/"
14
- },
15
- "response": {
16
- "status": 200,
17
- "body": "stubbing works"
18
- },
19
- "provider_state": "something is stubbed"
20
- }
21
- ]
22
- }
@@ -1,29 +0,0 @@
1
- require 'pact/provider/rspec'
2
- require 'rspec/mocks'
3
- require './spec/support/active_support_if_configured'
4
-
5
- class StubbedThing
6
- def self.stub_me
7
- end
8
- end
9
-
10
- class App
11
- def self.call env
12
- [200, {}, [StubbedThing.stub_me]]
13
- end
14
- end
15
-
16
- Pact.provider_states_for 'Consumer' do
17
- provider_state 'something is stubbed' do
18
- set_up do
19
- allow(StubbedThing).to receive(:stub_me).and_return("stubbing works")
20
- end
21
- end
22
- end
23
-
24
- # Include the ExampleMethods module after the provider states are declared
25
- # to ensure the ordering doesn't matter
26
-
27
- Pact.service_provider 'Provider' do
28
- app { App }
29
- end
@@ -1,48 +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
- "status": 200,
18
- "headers" : {
19
- "Content-type": {
20
- "json_class": "Pact::Term",
21
- "data": {
22
- "generate": "text/plain",
23
- "matcher": {
24
- "json_class": "Regexp",
25
- "o": 0,
26
- "s": "text"
27
- }
28
- }
29
- }
30
- },
31
- "body": {
32
- "message" : {
33
- "json_class": "Pact::Term",
34
- "data": {
35
- "generate": "rainy",
36
- "matcher": {
37
- "json_class": "Regexp",
38
- "o": 0,
39
- "s": "rain"
40
- }
41
- }
42
- }
43
- }
44
- },
45
- "provider_state": "the weather is sunny"
46
- }
47
- ]
48
- }
@@ -1,61 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "an unknown 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
- "status": 200,
18
- "headers" : {"Content-type": "application/json"},
19
- "body": {"message" : "this is not the weather you are looking for", "array": [{"foo": "bar"}], "somethingElse" : {"blah" : {"nested" : "that is missing"} }}
20
-
21
- },
22
- "provider_state": "the weather is cloudy"
23
- },{
24
- "description": "another test request",
25
- "request": {
26
- "method": "get",
27
- "path": "/weather",
28
- "query": ""
29
- },
30
- "response": {
31
- "status": 200,
32
- "headers" : {
33
- "Content-type": {
34
- "json_class": "Pact::Term",
35
- "data": {
36
- "generate": "application/hal+json",
37
- "matcher": {"json_class":"Regexp","o":0,"s":"hal"}
38
- }
39
- },
40
- "X-Special-Header": "something"
41
- },
42
- "body": {"message" : "this is not the weather you are looking for"}
43
-
44
- }
45
- },{
46
- "description": "another test request",
47
- "provider_state": "a missing provider state",
48
- "request": {
49
- "method": "get",
50
- "path": "/weather",
51
- "query": ""
52
- },
53
- "response": {
54
- "status": 200,
55
- "headers" : {"Content-type": "application/json"},
56
- "body": {"message" : "this is not the weather you are looking for"}
57
-
58
- }
59
- }
60
- ]
61
- }
@@ -1,38 +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
- "status": 200,
18
- "headers" : {"Content-type": "application/json"},
19
- "body": {"message" : "sunny"}
20
- },
21
- "provider_state": "the weather is sunny"
22
- },
23
- {
24
- "description": "a test request for text",
25
- "request": {
26
- "method": "get",
27
- "path": "/sometext",
28
- "query": "",
29
- "body" : "some request text"
30
- },
31
- "response": {
32
- "status": 200,
33
- "headers" : {"Content-type": "text/plain"},
34
- "body": "some text"
35
- }
36
- }
37
- ]
38
- }
@@ -1,23 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "some-test-consumer"
4
- },
5
- "provider": {
6
- "name": "the test app in the pact_helper file"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a test request expecting an application/json response",
11
- "request": {
12
- "method": "get",
13
- "path": "/content_type_is_important",
14
- "query": ""
15
- },
16
- "response": {
17
- "status": 200,
18
- "headers" : {"Content-type": "application/json"},
19
- "body": {"message" : "A message"}
20
- }
21
- }
22
- ]
23
- }
data/tasks/spec.rake DELETED
@@ -1,6 +0,0 @@
1
- require 'rspec/core/rake_task'
2
-
3
- RSpec::Core::RakeTask.new(:spec)
4
-
5
- task :default => [:spec]
6
-