pacto 0.4.0.rc1 → 0.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Gemfile +2 -7
  4. data/Rakefile +0 -5
  5. data/appveyor.yml +12 -0
  6. data/features/configuration/strict_matchers.feature +4 -4
  7. data/features/generate/generation.feature +8 -10
  8. data/features/support/env.rb +3 -7
  9. data/features/validate/validation.feature +3 -3
  10. data/lib/pacto.rb +5 -4
  11. data/lib/pacto/actors/json_generator.rb +1 -1
  12. data/lib/pacto/body_parsing.rb +42 -0
  13. data/lib/pacto/consumer/faraday_driver.rb +5 -2
  14. data/lib/pacto/contract.rb +23 -24
  15. data/lib/pacto/contract_factory.rb +4 -4
  16. data/lib/pacto/core/configuration.rb +18 -10
  17. data/lib/pacto/core/http_middleware.rb +1 -1
  18. data/lib/pacto/core/pacto_request.rb +3 -15
  19. data/lib/pacto/core/pacto_response.rb +3 -13
  20. data/lib/pacto/errors.rb +68 -0
  21. data/lib/pacto/formats/legacy/contract.rb +49 -0
  22. data/lib/pacto/formats/legacy/contract_builder.rb +129 -0
  23. data/lib/pacto/formats/legacy/contract_factory.rb +63 -0
  24. data/lib/pacto/formats/legacy/contract_generator.rb +77 -0
  25. data/lib/pacto/formats/legacy/generator/filters.rb +46 -0
  26. data/lib/pacto/formats/legacy/generator_hint.rb +36 -0
  27. data/lib/pacto/formats/legacy/request_clause.rb +39 -0
  28. data/lib/pacto/formats/legacy/response_clause.rb +31 -0
  29. data/lib/pacto/formats/swagger/contract.rb +86 -0
  30. data/lib/pacto/formats/swagger/contract_factory.rb +45 -0
  31. data/lib/pacto/formats/swagger/request_clause.rb +53 -0
  32. data/lib/pacto/formats/swagger/response_clause.rb +31 -0
  33. data/lib/pacto/generator.rb +4 -4
  34. data/lib/pacto/handlers/json_handler.rb +19 -0
  35. data/lib/pacto/handlers/text_handler.rb +17 -0
  36. data/lib/pacto/request_clause.rb +9 -19
  37. data/lib/pacto/response_clause.rb +4 -4
  38. data/lib/pacto/server.rb +41 -2
  39. data/lib/pacto/stubs/uri_pattern.rb +5 -5
  40. data/lib/pacto/stubs/webmock_adapter.rb +4 -1
  41. data/lib/pacto/test_helper.rb +16 -13
  42. data/lib/pacto/version.rb +1 -1
  43. data/pacto-server.gemspec +1 -3
  44. data/pacto.gemspec +1 -1
  45. data/sample_apis/user_api.rb +16 -0
  46. data/samples/contracts/user.json +51 -0
  47. data/samples/cops.rb +3 -0
  48. data/samples/server_cli.sh +3 -3
  49. data/spec/fabricators/contract_fabricator.rb +17 -8
  50. data/spec/fixtures/{deprecated_contracts → contracts/deprecated}/deprecated_contract.json +2 -2
  51. data/spec/fixtures/contracts/{contract.json → legacy/contract.json} +0 -0
  52. data/spec/fixtures/contracts/{contract_with_examples.json → legacy/contract_with_examples.json} +0 -0
  53. data/spec/fixtures/contracts/{simple_contract.json → legacy/simple_contract.json} +1 -1
  54. data/spec/fixtures/contracts/{strict_contract.json → legacy/strict_contract.json} +0 -0
  55. data/spec/fixtures/contracts/{templating_contract.json → legacy/templating_contract.json} +0 -0
  56. data/spec/fixtures/{swagger → contracts/swagger}/petstore.yaml +0 -0
  57. data/spec/integration/e2e_spec.rb +6 -12
  58. data/spec/integration/forensics/integration_matcher_spec.rb +5 -11
  59. data/spec/integration/rspec_spec.rb +12 -12
  60. data/spec/integration/templating_spec.rb +1 -1
  61. data/spec/spec_helper.rb +14 -2
  62. data/spec/unit/pacto/contract_factory_spec.rb +1 -2
  63. data/spec/unit/pacto/contract_spec.rb +44 -70
  64. data/spec/unit/pacto/core/investigation_spec.rb +4 -3
  65. data/spec/unit/pacto/formats/legacy/contract_builder_spec.rb +93 -0
  66. data/spec/unit/pacto/formats/legacy/contract_factory_spec.rb +29 -0
  67. data/spec/unit/pacto/formats/legacy/contract_generator_spec.rb +173 -0
  68. data/spec/unit/pacto/formats/legacy/contract_spec.rb +41 -0
  69. data/spec/unit/pacto/formats/legacy/generator/filters_spec.rb +104 -0
  70. data/spec/unit/pacto/formats/legacy/request_clause_spec.rb +79 -0
  71. data/spec/unit/pacto/formats/legacy/response_clause_spec.rb +45 -0
  72. data/spec/unit/pacto/formats/swagger/contract_factory_spec.rb +58 -0
  73. data/spec/unit/pacto/formats/swagger/contract_spec.rb +47 -0
  74. data/spec/unit/pacto/investigation_registry_spec.rb +1 -2
  75. data/spec/unit/pacto/pacto_spec.rb +6 -4
  76. data/spec/unit/pacto/stubs/uri_pattern_spec.rb +7 -8
  77. data/spec/unit/pacto/stubs/webmock_adapter_spec.rb +2 -4
  78. data/tasks/release.rake +1 -1
  79. metadata +53 -53
  80. data/lib/pacto/contract_builder.rb +0 -125
  81. data/lib/pacto/exceptions/invalid_contract.rb +0 -12
  82. data/lib/pacto/generator/filters.rb +0 -42
  83. data/lib/pacto/generator/hint.rb +0 -26
  84. data/lib/pacto/generator/native_contract_generator.rb +0 -74
  85. data/lib/pacto/native_contract_factory.rb +0 -60
  86. data/lib/pacto/swagger_contract_factory.rb +0 -90
  87. data/spec/pacto/dummy_server.rb +0 -4
  88. data/spec/pacto/dummy_server/dummy.rb +0 -51
  89. data/spec/pacto/dummy_server/jruby_workaround_helper.rb +0 -23
  90. data/spec/pacto/dummy_server/playback_servlet.rb +0 -22
  91. data/spec/unit/pacto/contract_builder_spec.rb +0 -89
  92. data/spec/unit/pacto/generator/filters_spec.rb +0 -100
  93. data/spec/unit/pacto/generator/native_contract_generator_spec.rb +0 -171
  94. data/spec/unit/pacto/native_contract_factory_spec.rb +0 -26
  95. data/spec/unit/pacto/request_clause_spec.rb +0 -75
  96. data/spec/unit/pacto/response_clause_spec.rb +0 -41
  97. data/spec/unit/pacto/server/playback_servlet_spec.rb +0 -27
  98. data/spec/unit/pacto/swagger_contract_factory_spec.rb +0 -56
@@ -1,100 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module Pacto
3
- module Generator
4
- describe Filters do
5
- let(:record_host) do
6
- 'http://example.com'
7
- end
8
- let(:request) do
9
- RequestClause.new(
10
- host: record_host,
11
- http_method: 'GET',
12
- path: '/abcd',
13
- headers: {
14
- 'Server' => ['example.com'],
15
- 'Connection' => ['Close'],
16
- 'Content-Length' => [1234],
17
- 'Via' => ['Some Proxy'],
18
- 'User-Agent' => ['rspec']
19
- },
20
- params: {
21
- 'apikey' => "<%= ENV['MY_API_KEY'] %>"
22
- }
23
- )
24
- end
25
- let(:varies) { ['User-Agent'] }
26
- let(:response) do
27
- Faraday::Response.new(
28
- status: 200,
29
- response_headers: {
30
- 'Date' => Time.now.rfc2822,
31
- 'Last-Modified' => Time.now.rfc2822,
32
- 'ETag' => 'abc123',
33
- 'Server' => ['Fake Server'],
34
- 'Content-Type' => ['application/json'],
35
- 'Vary' => varies
36
- },
37
- body: double('dummy body')
38
- )
39
- end
40
-
41
- describe '#filter_request_headers' do
42
- subject(:filtered_request_headers) { described_class.new.filter_request_headers(request, response).keys.map(&:downcase) }
43
- it 'keeps important request headers' do
44
- expect(filtered_request_headers).to include 'user-agent'
45
- end
46
-
47
- it 'filters informational request headers' do
48
- expect(filtered_request_headers).not_to include 'via'
49
- expect(filtered_request_headers).not_to include 'date'
50
- expect(filtered_request_headers).not_to include 'server'
51
- expect(filtered_request_headers).not_to include 'content-length'
52
- expect(filtered_request_headers).not_to include 'connection'
53
- end
54
-
55
- context 'multiple Vary elements' do
56
- context 'as a single string' do
57
- let(:varies) do
58
- ['User-Agent,Via']
59
- end
60
- it 'keeps each header' do
61
- expect(filtered_request_headers).to include 'user-agent'
62
- expect(filtered_request_headers).to include 'via'
63
- end
64
- end
65
- context 'as multiple items' do
66
- let(:varies) do
67
- %w(User-Agent Via)
68
- end
69
- it 'keeps each header' do
70
- expect(filtered_request_headers).to include 'user-agent'
71
- expect(filtered_request_headers).to include 'via'
72
- end
73
- end
74
- end
75
- end
76
-
77
- describe '#filter_response_headers' do
78
- subject(:filtered_response_headers) { described_class.new.filter_response_headers(request, response).keys.map(&:downcase) }
79
- it 'keeps important response headers' do
80
- expect(filtered_response_headers).to include 'content-type'
81
- end
82
-
83
- it 'filters connection control headers' do
84
- expect(filtered_response_headers).not_to include 'content-length'
85
- expect(filtered_response_headers).not_to include 'via'
86
- end
87
-
88
- it 'filters freshness headers' do
89
- expect(filtered_response_headers).not_to include 'date'
90
- expect(filtered_response_headers).not_to include 'last-modified'
91
- expect(filtered_response_headers).not_to include 'eTag'
92
- end
93
-
94
- it 'filters x-* headers' do
95
- expect(filtered_response_headers).not_to include 'x-men'
96
- end
97
- end
98
- end
99
- end
100
- end
@@ -1,171 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module Pacto
3
- module Generator
4
- describe NativeContractGenerator do
5
- let(:record_host) do
6
- 'http://example.com'
7
- end
8
- let(:request_clause) { Fabricate(:request_clause, params: { 'api_key' => "<%= ENV['MY_API_KEY'] %>" }) }
9
- let(:response_adapter) do
10
- Faraday::Response.new(
11
- status: 200,
12
- response_headers: {
13
- 'Date' => [Time.now],
14
- 'Server' => ['Fake Server'],
15
- 'Content-Type' => ['application/json'],
16
- 'Vary' => ['User-Agent']
17
- },
18
- body: 'dummy body' # body is just a string
19
- )
20
- end
21
- let(:filtered_request_headers) { double('filtered_response_headers') }
22
- let(:filtered_response_headers) { double('filtered_response_headers') }
23
- let(:response_body_schema) { '{"message": "dummy generated schema"}' }
24
- let(:version) { 'draft3' }
25
- let(:schema_generator) { double('schema_generator') }
26
- let(:validator) { double('validator') }
27
- let(:filters) { double :filters }
28
- let(:consumer) { double 'consumer' }
29
- let(:request_file) { 'request.json' }
30
- let(:generator) { described_class.new version, schema_generator, validator, filters, consumer }
31
- let(:request_contract) do
32
- Fabricate(:partial_contract, request: request_clause, file: request_file)
33
- end
34
- let(:request) do
35
- Pacto.configuration.default_consumer.build_request request_contract
36
- end
37
-
38
- def pretty(obj)
39
- MultiJson.encode(obj, pretty: true).gsub(/^$\n/, '')
40
- end
41
-
42
- describe '#generate_from_partial_contract' do
43
- # TODO: Deprecate partial contracts?
44
- let(:generated_contract) { Fabricate(:contract) }
45
- before do
46
- expect(Pacto).to receive(:load_contract).with(request_file, record_host).and_return request_contract
47
- expect(consumer).to receive(:request).with(request_contract).and_return([request, response_adapter])
48
- end
49
-
50
- it 'parses the request' do
51
- expect(generator).to receive(:save).with(request_file, request, anything)
52
- generator.generate_from_partial_contract request_file, record_host
53
- end
54
-
55
- it 'fetches a response' do
56
- expect(generator).to receive(:save).with(request_file, anything, response_adapter)
57
- generator.generate_from_partial_contract request_file, record_host
58
- end
59
-
60
- it 'saves the result' do
61
- expect(generator).to receive(:save).with(request_file, request, response_adapter).and_return generated_contract
62
- expect(generator.generate_from_partial_contract request_file, record_host).to eq(generated_contract)
63
- end
64
- end
65
-
66
- describe '#save' do
67
- before do
68
- allow(filters).to receive(:filter_request_headers).with(request, response_adapter).and_return filtered_request_headers
69
- allow(filters).to receive(:filter_response_headers).with(request, response_adapter).and_return filtered_response_headers
70
- end
71
- context 'invalid schema' do
72
- it 'raises an error if schema generation fails' do
73
- expect(schema_generator).to receive(:generate).and_raise ArgumentError.new('Could not generate schema')
74
- expect { generator.save request_file, request, response_adapter }.to raise_error
75
- end
76
-
77
- it 'raises an error if the generated contract is invalid' do
78
- expect(schema_generator).to receive(:generate).and_return response_body_schema
79
- expect(validator).to receive(:validate).and_raise InvalidContract.new('dummy error')
80
- expect { generator.save request_file, request, response_adapter }.to raise_error
81
- end
82
- end
83
-
84
- context 'valid schema' do
85
- let(:raw_contract) do
86
- expect(schema_generator).to receive(:generate).with(request_file, response_adapter.body, Pacto.configuration.generator_options).and_return response_body_schema
87
- expect(validator).to receive(:validate).and_return true
88
- generator.save request_file, request, response_adapter
89
- end
90
- subject(:generated_contract) { JSON.parse raw_contract }
91
-
92
- it 'sets the schema to the generated json-schema' do
93
- expect(subject['response']['schema']).to eq(JSON.parse response_body_schema)
94
- end
95
-
96
- it 'sets the request attributes' do
97
- generated_request = subject['request']
98
- expect(generated_request['params']).to eq(request.uri.query_values)
99
- expect(generated_request['path']).to eq(request.uri.path)
100
- end
101
-
102
- it 'preserves ERB in the request params' do
103
- generated_request = subject['request']
104
- expect(generated_request['params']).to eq('api_key' => "<%= ENV['MY_API_KEY'] %>")
105
- end
106
-
107
- it 'normalizes the request method' do
108
- generated_request = subject['request']
109
- expect(generated_request['http_method']).to eq(request.method.downcase.to_s)
110
- end
111
-
112
- it 'sets the response attributes' do
113
- generated_response = subject['response']
114
- expect(generated_response['status']).to eq(response_adapter.status)
115
- end
116
-
117
- it 'generates pretty JSON' do
118
- expect(raw_contract).to eq(pretty(subject))
119
- end
120
- end
121
-
122
- context 'with hints' do
123
- let(:request1) { Fabricate(:pacto_request, host: 'example.com', path: '/album/5/cover') }
124
- let(:request2) { Fabricate(:pacto_request, host: 'example.com', path: '/album/7/cover') }
125
- let(:response1) { Fabricate(:pacto_response) }
126
- let(:response2) { Fabricate(:pacto_response) }
127
- let(:contracts_path) { Dir.mktmpdir }
128
-
129
- before(:each) do
130
- allow(filters).to receive(:filter_request_headers).with(request1, response1).and_return request1.headers
131
- allow(filters).to receive(:filter_response_headers).with(request1, response1).and_return response1.headers
132
- allow(filters).to receive(:filter_request_headers).with(request2, response2).and_return request2.headers
133
- allow(filters).to receive(:filter_response_headers).with(request2, response2).and_return response2.headers
134
- allow(schema_generator).to receive(:generate).with(request_file, response1.body, Pacto.configuration.generator_options).and_return response_body_schema
135
- allow(schema_generator).to receive(:generate).with(request_file, response2.body, Pacto.configuration.generator_options).and_return response_body_schema
136
- allow(validator).to receive(:validate).twice.and_return true
137
- Pacto.configuration.contracts_path = contracts_path
138
- Pacto::Generator.configure do |c|
139
- c.hint 'Get Album Cover', http_method: :get, host: 'http://example.com', path: '/album/{id}/cover', target_file: 'album_services/get_album_cover.json'
140
- end
141
- Pacto.generate!
142
- end
143
-
144
- it 'names the contract based on the hint' do
145
- contract1 = generator.generate request1, response1
146
- expect(contract1.name).to eq('Get Album Cover')
147
- end
148
-
149
- it 'sets the path to match the hint' do
150
- contract1 = generator.generate request1, response1
151
- expect(contract1.request.path).to eq('/album/{id}/cover')
152
- end
153
-
154
- it 'sets the target file based on the hint' do
155
- contract1 = generator.generate request1, response1
156
- expected_path = File.expand_path('album_services/get_album_cover.json', contracts_path)
157
- real_expected_path = Pathname.new(expected_path).realpath.to_s
158
- expected_file_uri = Addressable::URI.convert_path(real_expected_path).to_s
159
- expect(contract1.file).to eq(expected_file_uri)
160
- end
161
-
162
- xit 'does not create duplicate contracts' do
163
- contract1 = generator.generate request1, response1
164
- contract2 = generator.generate request2, response2
165
- expect(contract1).to eq(contract2)
166
- end
167
- end
168
- end
169
- end
170
- end
171
- end
@@ -1,26 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
3
-
4
- module Pacto
5
- describe NativeContractFactory do
6
- let(:host) { 'http://localhost' }
7
- let(:contract_name) { 'contract' }
8
- let(:contracts_path) { %w(spec fixtures contracts) }
9
- let(:contract_path) { File.join(contracts_path, "#{contract_name}.json") }
10
- subject(:contract_factory) { described_class.new }
11
-
12
- it 'builds a contract given a JSON file path and a host' do
13
- contract = contract_factory.build_from_file(contract_path, host)
14
- expect(contract).to be_a(Contract)
15
- end
16
-
17
- context 'deprecated contracts' do
18
- let(:contracts_path) { %w(spec fixtures deprecated_contracts) }
19
- let(:contract_name) { 'deprecated_contract' }
20
- it 'can still be loaded' do
21
- contract = contract_factory.build_from_file(contract_path, host)
22
- expect(contract).to be_a(Contract)
23
- end
24
- end
25
- end
26
- end
@@ -1,75 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module Pacto
3
- describe RequestClause do
4
- let(:host) { 'http://localhost' }
5
- let(:method) { 'GET' }
6
- let(:path) { '/hello_world' }
7
- let(:headers) { { 'accept' => 'application/json' } }
8
- let(:params) { { 'foo' => 'bar' } }
9
- let(:body) { double :body }
10
- let(:params_as_json) { "{\"foo\":\"bar\"}" }
11
- let(:absolute_uri) { "#{host}#{path}" }
12
- subject(:request) do
13
- req_hash = {
14
- host: host,
15
- 'http_method' => method,
16
- 'path' => path,
17
- 'headers' => headers,
18
- 'params' => params
19
- }
20
- # The default test is for missing keys, not explicitly nil keys
21
- req_hash.merge!('schema' => body) if body
22
- described_class.new(req_hash)
23
- end
24
-
25
- it 'has a host' do
26
- expect(request.host).to eq host
27
- end
28
-
29
- describe '#http_method' do
30
- it 'delegates to definition' do
31
- expect(request.http_method).to eq :get
32
- end
33
-
34
- it 'downcases the method' do
35
- expect(request.http_method).to eq request.http_method.downcase
36
- end
37
-
38
- it 'returns a symbol' do
39
- expect(request.http_method).to be_kind_of Symbol
40
- end
41
- end
42
-
43
- describe '#schema' do
44
- it 'delegates to definition\'s body' do
45
- expect(request.schema).to eq body
46
- end
47
-
48
- describe 'when definition does not have a schema' do
49
- let(:body) { nil }
50
-
51
- it 'returns an empty empty hash' do
52
- expect(request.schema).to eq({})
53
- end
54
- end
55
- end
56
-
57
- describe '#path' do
58
- it 'delegates to definition' do
59
- expect(request.path).to eq path
60
- end
61
- end
62
-
63
- describe '#headers' do
64
- it 'delegates to definition' do
65
- expect(request.headers).to eq headers
66
- end
67
- end
68
-
69
- describe '#params' do
70
- it 'delegates to definition' do
71
- expect(request.params).to eq params
72
- end
73
- end
74
- end
75
- end
@@ -1,41 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module Pacto
3
- describe ResponseClause do
4
- let(:body_definition) do
5
- Fabricate(:schema)
6
- end
7
-
8
- let(:definition) do
9
- {
10
- 'status' => 200,
11
- 'headers' => {
12
- 'Content-Type' => 'application/json'
13
- },
14
- 'schema' => body_definition
15
- }
16
- end
17
-
18
- subject(:response) { described_class.new(definition) }
19
-
20
- it 'has a status' do
21
- expect(response.status).to eq(200)
22
- end
23
-
24
- it 'has a headers hash' do
25
- expect(response.headers).to eq(
26
- 'Content-Type' => 'application/json'
27
- )
28
- end
29
-
30
- it 'has a schema' do
31
- expect(response.schema).to eq(body_definition)
32
- end
33
-
34
- it 'has a default value for the schema' do
35
- definition.delete 'schema'
36
- response = described_class.new(definition)
37
- expect(response.schema).to eq(Hash.new)
38
- end
39
-
40
- end
41
- end
@@ -1,27 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module Pacto
3
- module DummyServer
4
- describe PlaybackServlet do
5
- let(:request) { double }
6
- let(:response) { double('response', :status= => '', :[]= => '', :body= => '') }
7
-
8
- it 'alters response data with recorded status' do
9
- servlet = PlaybackServlet.new status: 200
10
- servlet.do_GET(request, response)
11
- expect(response).to have_received(:status=).with(200)
12
- end
13
-
14
- it 'alters reponse data with recorded headers' do
15
- servlet = PlaybackServlet.new headers: { 'Content-Type' => 'application/json' }
16
- servlet.do_GET(request, response)
17
- expect(response).to have_received(:[]=).with('Content-Type', 'application/json')
18
- end
19
-
20
- it 'alters reponse data with recorded ' do
21
- servlet = PlaybackServlet.new body: 'recorded'
22
- servlet.do_GET(request, response)
23
- expect(response).to have_received(:body=).with('recorded')
24
- end
25
- end
26
- end
27
- end
@@ -1,56 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- module Pacto
3
- module Generator
4
- describe SwaggerContractFactory do
5
- let(:swagger_file) { 'spec/fixtures/swagger/petstore.yaml' }
6
- let(:expected_schema) do
7
- {
8
- 'type' => 'array',
9
- 'items' => {
10
- 'required' => %w(id name),
11
- 'properties' => {
12
- 'id' => { 'type' => 'integer', 'format' => 'int64' },
13
- 'name' => { 'type' => 'string' },
14
- 'tag' => { 'type' => 'string' }
15
- }
16
- }
17
- }
18
- end
19
- describe '#load_hints' do
20
- it 'loads hints from Swagger' do
21
- hints = subject.load_hints(swagger_file)
22
- expect(hints.size).to eq(3) # number of API operations
23
- hints.each do | hint |
24
- expect(hint).to be_a_kind_of(Pacto::Generator::Hint)
25
- expect(hint.host).to eq('petstore.swagger.wordnik.com')
26
- expect([:get, :post]).to include(hint.http_method)
27
- expect(hint.path).to match(/\/pets/)
28
- end
29
- end
30
- end
31
-
32
- describe '#build_from_file' do
33
- it 'loads Contracts from Swagger' do
34
- contracts = subject.build_from_file(swagger_file)
35
- expect(contracts.size).to eq(3) # number of API operations
36
- contracts.each do | contract |
37
- expect(contract).to be_a_kind_of(Pacto::Contract)
38
-
39
- request_clause = contract.request
40
- expect(request_clause.host).to eq('petstore.swagger.wordnik.com')
41
- expect([:get, :post]).to include(request_clause.http_method)
42
- expect(request_clause.path).to match(/\/pets/)
43
-
44
- response_clause = contract.response
45
- if request_clause.http_method == :get
46
- expect(response_clause.status).to eq(200)
47
- else
48
- expect(response_clause.status).to eq(201)
49
- end
50
- expect(response_clause.schema).to eq(expected_schema) if response_clause.status == 200
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end