Skip to content

Commit 3bed570

Browse files
committed
[fix] tests
1 parent 57d12c3 commit 3bed570

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
zero-rails_openapi (1.5.8)
4+
zero-rails_openapi (1.5.9)
55
activesupport (>= 3)
66
colorize
77
rails (>= 3)

lib/open_api/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module OpenApi
2-
VERSION = '1.5.8'
2+
VERSION = '1.5.9'
33
end

spec/components_spec.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
require 'spec_dsl'
22

3+
def clear
4+
after_do { @doc_info[:components] = { } }
5+
end
6+
37
RSpec.describe OpenApi::DSL::Components do
48
get_and_dig_doc [:components]
59
let(:dsl_in) { [:components] }
610

711
desc :schema, subject: :schemas do
812
correct do
9-
mk -> { schema :SchemaA, String; schema :SchemaZ, String }, doc_will_has_keys: { schemas: %i[ SchemaA SchemaZ ] }
13+
mk -> { schema :SchemaA, String; schema :SchemaZ, String }, doc_will_has_keys: { schemas: %i[ SchemaA SchemaZ ] }; clear
1014

11-
mk -> { schema :SchemaA, String }, get: { SchemaA: { type: 'string'} }
12-
mk -> { schema :SchemaA, type: Integer }, get: { SchemaA: { type: 'integer'} }
13-
mk -> { schema :SchemaB => [ String ] }, get: { SchemaB: { type: 'string'} }
14-
mk -> { schema :SchemaC => [ type: String, desc: 'test' ] }, get: { SchemaC: { type: 'string', description: 'test' } }
15+
mk -> { schema :SchemaA, String }, get: { SchemaA: { type: 'string'} }; clear
16+
mk -> { schema :SchemaA, type: Integer }, get: { SchemaA: { type: 'integer'} }; clear
17+
mk -> { schema :SchemaB => [ String ] }, get: { SchemaB: { type: 'string'} }; clear
18+
mk -> { schema :SchemaC => [ type: String, desc: 'test' ] }, get: { SchemaC: { type: 'string', description: 'test' } }; clear
1519

1620
context 'when defining combined schema' do
1721
mk -> { schema :SchemaD => [ one_of: [String] ] }, has_keys: { SchemaD: [:oneOf] }
@@ -25,7 +29,7 @@
2529

2630

2731
desc :example, subject: :examples do
28-
mk -> { example :ExampleA, { }; example :ExampleZ, { } }, doc_will_has_keys: { examples: %i[ ExampleA ExampleZ ] }
32+
mk -> { example :ExampleA, { }; example :ExampleZ, { } }, doc_will_has_keys: { examples: %i[ ExampleA ExampleZ ] }; clear
2933
mk -> { example :ExampleA, { name: 'BeiGou' } }, get: { ExampleA: [{ name: { value: 'BeiGou' } }] }
3034
end
3135

@@ -43,7 +47,7 @@
4347
expect_its :name, eq: :page
4448
expect_its :in, eq: 'query'
4549
expect_its :required, eq: false
46-
expect_its :schema, eq: { type: 'integer' }
50+
expect_its :schema, eq: { type: 'integer' }; clear
4751

4852
mk -> { path :PathId => [ :id, Integer ] }, has_keys: { PathId: its_structure << { schema: [:type] } }
4953

@@ -107,7 +111,7 @@
107111
mk -> do
108112
response :RespA, 'invalid token'
109113
response :RespZ, 'parameter validation failed'
110-
end, doc_will_has_keys: { responses: %i[ RespA RespZ ] }
114+
end, doc_will_has_keys: { responses: %i[ RespA RespZ ] }; clear
111115

112116
mk -> { resp :RespA => [ 'desc', :json ] }, has_keys!: { RespA: its_structure }
113117
focus_on :RespA
@@ -124,14 +128,14 @@
124128
authorizationUrl: 'https://example.com/api/oauth/dialog',
125129
scopes: { 'write:pets': 'modify pets in your account', 'read:pets': 'read your pets' }
126130
} }, desc: 'desc'
127-
end, doc_will_has_keys: { securitySchemes: %i[ OAuth ] }
131+
end, doc_will_has_keys: { securitySchemes: %i[ OAuth ] }; clear
128132

129133
describe '#base_auth' do
130-
mk -> { base_auth :BaseAuth }, get: { BaseAuth: { type: 'http', scheme: 'basic' }}
134+
mk -> { base_auth :BaseAuth }, get: { BaseAuth: { type: 'http', scheme: 'basic' } }; clear
131135
end
132136

133137
describe '#bearer_auth' do
134-
mk -> { bearer_auth :Token }, get: { Token: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' }}
138+
mk -> { bearer_auth :Token }, get: { Token: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' } }; clear
135139
end
136140

137141
describe '#api_key' do

0 commit comments

Comments
 (0)