open_api-rspec 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0eaa152838fc212c77475757db2bc43f6578981f2c3d5f798921aec151eff980
4
- data.tar.gz: f497e89a621ddbc452caf3fd14724cc0531a16ec2ee7ed91503b1fe45af0c49b
3
+ metadata.gz: 3741968c9b4462297e6b5133bbfeb867925a9a66ffeb6df80071a0d59092eac2
4
+ data.tar.gz: 7d1a054818ed563c3dfc0e12c59ff928429e28149090cf63bb4f96d83b75a614
5
5
  SHA512:
6
- metadata.gz: 5341b04617825182b2a652108a6c182ea52ef0dbe55db9c2e2bb444a3c064cd2331d25693b641ac56406d2ce2a52efe979f8407dc56d78f2b621d881421967c5
7
- data.tar.gz: d0fcf7ef8a0f618a0d67524a8ed058e95d74f2069dbe0546512fa6a4964d3312e06a91b65cf9d49da065e87de44bbe32aefe762eed29f3bca0d065a532b5b713
6
+ metadata.gz: 36034881ca126efae00820d2820e173c2e2eef1416213e43c3b0e5a2994d698d0eef712c3a222966c76e558a4fcf0e6cafbd3dc9e60687786dbb475c1b3b0af6
7
+ data.tar.gz: 9f1bff37f4299fb0672b5bc1dae5d0df04024e5313dd77752d26f9d620b449b2391c2b73a79e2823d321b456eb1bc932c817ab80866753d012359400e5db8f16
@@ -0,0 +1,64 @@
1
+ ---
2
+ detectors:
3
+ DuplicateMethodCall:
4
+ exclude:
5
+ - OpenApi::RSpec::SchemaParser#deep_body_keys
6
+ - OpenApi::RSpec::SchemaParser#get_deep_keys
7
+ - OpenApi::RSpec::SchemaParser#initialize
8
+ - OpenApi::RSpec::SchemaParser#openapi_body_params
9
+ - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_and_response_status
10
+ - OpenApi::RSpec::SchemaParser#openapi_form_data_params
11
+ FeatureEnvy:
12
+ exclude:
13
+ - OpenApi::RSpec::SchemaParser#deep_body_keys
14
+ - OpenApi::RSpec::SchemaParser#get_deep_keys
15
+ - OpenApi::RSpec::SchemaParser#openapi_required_form_data_params
16
+ - OpenApi::RSpec::SchemaParser#openapi_required_path_params
17
+ - OpenApi::RSpec::SchemaParser#openapi_required_query_string_params
18
+ - OpenApi::RSpec::SchemaParser#openapi_form_data_params
19
+ NestedIterators:
20
+ exclude:
21
+ - OpenApi::RSpec::SchemaParser#deep_body_keys
22
+ - OpenApi::RSpec::SchemaParser#get_deep_keys
23
+ - OpenApi::RSpec::SchemaParser#initialize
24
+ - OpenApi::RSpec::SchemaParser#openapi_body_params
25
+ - OpenApi::RSpec::SchemaParser#openapi_form_data_params
26
+ TooManyInstanceVariables:
27
+ exclude:
28
+ - OpenApi::RSpec::SchemaParser
29
+ TooManyMethods:
30
+ exclude:
31
+ - OpenApi::RSpec::SchemaParser
32
+ TooManyStatements:
33
+ exclude:
34
+ - initialize
35
+ - OpenApi::RSpec::SchemaParser#deep_body_keys
36
+ - OpenApi::RSpec::SchemaParser#get_deep_keys
37
+ - OpenApi::RSpec::SchemaParser#openapi_body_params
38
+ - OpenApi::RSpec::SchemaParser#openapi_form_data_params
39
+ UncommunicativeVariableName:
40
+ exclude:
41
+ - OpenApi::RSpec::SchemaParser#get_deep_keys
42
+ - OpenApi::RSpec::SchemaParser#initialize
43
+ - OpenApi::RSpec::SchemaParser#openapi_body_params
44
+ - OpenApi::RSpec::SchemaParser#openapi_form_data_params
45
+ - OpenApi::RSpec::SchemaParser#openapi_path_params
46
+ - OpenApi::RSpec::SchemaParser#openapi_query_string_params
47
+ - OpenApi::RSpec::SchemaParser#openapi_required_form_data_params
48
+ - OpenApi::RSpec::SchemaParser#openapi_required_path_params
49
+ - OpenApi::RSpec::SchemaParser#openapi_required_query_string_params
50
+ - OpenApi::RSpec::SchemaParser#request_path_params
51
+ - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_body_parameters
52
+ - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_form_data_parameters
53
+ - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_path_parameters
54
+ - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_query_string_parameters
55
+ UtilityFunction:
56
+ exclude:
57
+ - OpenApi::RSpec::SchemaParser#has_documented_param_in_openapi_url_fragments
58
+ - OpenApi::RSpec::SchemaParser#openapi_url_fragment_name
59
+
60
+ IrresponsibleModule:
61
+ enabled: false
62
+
63
+ exclude_paths:
64
+ - vendor/bundle
@@ -18,7 +18,7 @@ Metrics/AbcSize:
18
18
  # Offense count: 6
19
19
  # Configuration parameters: CountComments, ExcludedMethods.
20
20
  Metrics/BlockLength:
21
- Max: 56
21
+ Max: 73
22
22
 
23
23
  # Offense count: 1
24
24
  # Configuration parameters: CountBlocks.
@@ -28,7 +28,7 @@ Metrics/BlockNesting:
28
28
  # Offense count: 1
29
29
  # Configuration parameters: CountComments.
30
30
  Metrics/ClassLength:
31
- Max: 183
31
+ Max: 192
32
32
 
33
33
  # Offense count: 1
34
34
  Metrics/CyclomaticComplexity:
@@ -67,3 +67,6 @@ Style/NumericPredicate:
67
67
  Exclude:
68
68
  - 'spec/**/*'
69
69
  - 'lib/open_api/rspec/schema_parser.rb'
70
+
71
+ RSpec/SharedExamples:
72
+ Enabled: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- open_api-rspec (0.1.5)
4
+ open_api-rspec (0.1.6)
5
5
  activesupport
6
6
  open_api-schema_validator
7
7
  rspec
@@ -9,22 +9,22 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (5.1.5)
13
- actionview (= 5.1.5)
14
- activesupport (= 5.1.5)
12
+ actionpack (5.2.0)
13
+ actionview (= 5.2.0)
14
+ activesupport (= 5.2.0)
15
15
  rack (~> 2.0)
16
16
  rack-test (>= 0.6.3)
17
17
  rails-dom-testing (~> 2.0)
18
18
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
- actionview (5.1.5)
20
- activesupport (= 5.1.5)
19
+ actionview (5.2.0)
20
+ activesupport (= 5.2.0)
21
21
  builder (~> 3.1)
22
22
  erubi (~> 1.4)
23
23
  rails-dom-testing (~> 2.0)
24
24
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
25
- activesupport (5.1.5)
25
+ activesupport (5.2.0)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
- i18n (~> 0.7)
27
+ i18n (>= 0.7, < 2)
28
28
  minitest (~> 5.1)
29
29
  tzinfo (~> 1.1)
30
30
  addressable (2.5.2)
@@ -34,33 +34,35 @@ GEM
34
34
  descendants_tracker (~> 0.0.4)
35
35
  ice_nine (~> 0.11.0)
36
36
  thread_safe (~> 0.3, >= 0.3.1)
37
- brakeman (4.2.0)
37
+ brakeman (4.3.1)
38
38
  builder (3.2.3)
39
39
  bundler-audit (0.6.0)
40
40
  bundler (~> 1.2)
41
41
  thor (~> 0.18)
42
- byebug (10.0.0)
42
+ byebug (10.0.2)
43
43
  codeclimate-engine-rb (0.4.1)
44
44
  virtus (~> 1.0)
45
45
  coderay (1.1.2)
46
46
  coercible (1.0.0)
47
47
  descendants_tracker (~> 0.0.1)
48
48
  concurrent-ruby (1.0.5)
49
- crass (1.0.3)
49
+ crass (1.0.4)
50
50
  descendants_tracker (0.0.4)
51
51
  thread_safe (~> 0.3, >= 0.3.1)
52
52
  diff-lcs (1.3)
53
- docile (1.1.5)
53
+ docile (1.3.1)
54
54
  equalizer (0.0.11)
55
- erubi (1.7.0)
56
- httparty (0.16.0)
55
+ erubi (1.7.1)
56
+ httparty (0.16.2)
57
57
  multi_xml (>= 0.5.2)
58
- i18n (0.9.5)
58
+ i18n (1.0.1)
59
59
  concurrent-ruby (~> 1.0)
60
60
  ice_nine (0.11.2)
61
+ jaro_winkler (1.5.1)
61
62
  json (2.1.0)
62
63
  json-schema (2.8.0)
63
64
  addressable (>= 2.4)
65
+ kwalify (0.7.2)
64
66
  lois (0.1.6)
65
67
  activesupport
66
68
  brakeman
@@ -70,21 +72,21 @@ GEM
70
72
  rubocop
71
73
  simplecov
72
74
  thor
73
- loofah (2.2.0)
75
+ loofah (2.2.2)
74
76
  crass (~> 1.0.2)
75
77
  nokogiri (>= 1.5.9)
76
78
  method_source (0.9.0)
77
79
  mini_portile2 (2.3.0)
78
80
  minitest (5.11.3)
79
81
  multi_xml (0.6.0)
80
- nokogiri (1.8.2)
82
+ nokogiri (1.8.4)
81
83
  mini_portile2 (~> 2.3.0)
82
84
  open_api-schema_validator (0.1.0)
83
85
  json-schema
84
86
  parallel (1.12.1)
85
- parser (2.4.0.2)
86
- ast (~> 2.3)
87
- powerpack (0.1.1)
87
+ parser (2.5.1.2)
88
+ ast (~> 2.4.0)
89
+ powerpack (0.1.2)
88
90
  pry (0.11.3)
89
91
  coderay (~> 1.1.0)
90
92
  method_source (~> 0.9.0)
@@ -92,21 +94,21 @@ GEM
92
94
  byebug (~> 10.0)
93
95
  pry (~> 0.10)
94
96
  public_suffix (3.0.2)
95
- rack (2.0.4)
96
- rack-test (0.8.2)
97
+ rack (2.0.5)
98
+ rack-test (1.1.0)
97
99
  rack (>= 1.0, < 3)
98
100
  rails-dom-testing (2.0.3)
99
101
  activesupport (>= 4.2.0)
100
102
  nokogiri (>= 1.6)
101
- rails-html-sanitizer (1.0.3)
102
- loofah (~> 2.0)
103
- rainbow (2.2.2)
104
- rake
105
- rake (12.3.0)
106
- reek (4.7.3)
103
+ rails-html-sanitizer (1.0.4)
104
+ loofah (~> 2.2, >= 2.2.2)
105
+ rainbow (3.0.0)
106
+ rake (12.3.1)
107
+ reek (5.0.2)
107
108
  codeclimate-engine-rb (~> 0.4.0)
108
- parser (>= 2.4.0.0, < 2.5)
109
- rainbow (~> 2.0)
109
+ kwalify (~> 0.7.0)
110
+ parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
111
+ rainbow (>= 2.0, < 4.0)
110
112
  rspec (3.7.0)
111
113
  rspec-core (~> 3.7.0)
112
114
  rspec-expectations (~> 3.7.0)
@@ -120,18 +122,19 @@ GEM
120
122
  diff-lcs (>= 1.2.0, < 2.0)
121
123
  rspec-support (~> 3.7.0)
122
124
  rspec-support (3.7.1)
123
- rubocop (0.52.1)
125
+ rubocop (0.58.2)
126
+ jaro_winkler (~> 1.5.1)
124
127
  parallel (~> 1.10)
125
- parser (>= 2.4.0.2, < 3.0)
128
+ parser (>= 2.5, != 2.5.1.1)
126
129
  powerpack (~> 0.1)
127
130
  rainbow (>= 2.2.2, < 4.0)
128
131
  ruby-progressbar (~> 1.7)
129
132
  unicode-display_width (~> 1.0, >= 1.0.1)
130
- rubocop-rspec (1.23.0)
131
- rubocop (>= 0.52.1)
133
+ rubocop-rspec (1.27.0)
134
+ rubocop (>= 0.56.0)
132
135
  ruby-progressbar (1.9.0)
133
- simplecov (0.15.1)
134
- docile (~> 1.1.0)
136
+ simplecov (0.16.1)
137
+ docile (~> 1.1)
135
138
  json (>= 1.8, < 3)
136
139
  simplecov-html (~> 0.10.0)
137
140
  simplecov-html (0.10.2)
@@ -139,7 +142,7 @@ GEM
139
142
  thread_safe (0.3.6)
140
143
  tzinfo (1.2.5)
141
144
  thread_safe (~> 0.1)
142
- unicode-display_width (1.3.0)
145
+ unicode-display_width (1.4.0)
143
146
  virtus (1.0.5)
144
147
  axiom-types (~> 0.1)
145
148
  coercible (~> 1.0)
@@ -162,4 +165,4 @@ DEPENDENCIES
162
165
  simplecov
163
166
 
164
167
  BUNDLED WITH
165
- 1.16.1
168
+ 1.16.2
@@ -138,7 +138,16 @@ module OpenApi
138
138
  end
139
139
 
140
140
  def openapi_form_data_params
141
- schema_for_url_and_request_method_form_data_parameters.map { |p| p['name'].to_s }
141
+ schema_for_url_and_request_method_form_data_parameters.flat_map do |p|
142
+ if p['schema'].present?
143
+ keys = p['schema']['properties'].flat_map do |k, v|
144
+ deep_body_keys(k, v)
145
+ end
146
+ keys.map { |key| "#{p['name']}##{key}" }
147
+ else
148
+ p['name'].to_s
149
+ end
150
+ end
142
151
  end
143
152
 
144
153
  def openapi_body_params
@@ -8,45 +8,69 @@ module OpenApi
8
8
  let(:schema_parser) { OpenApi::RSpec::SchemaParser.new(schema_hash, request, response) }
9
9
 
10
10
  it 'has openapi documentation for url' do
11
- expect(schema_parser.schema_for_url).not_to be_nil
11
+ expect(schema_parser.schema_for_url).not_to(
12
+ be_nil,
13
+ 'url not documented'
14
+ )
12
15
  end
13
16
 
14
17
  it 'matches an allowed http request method' do
15
- expect(schema_parser.schema_for_url_and_request_method).not_to be_nil
18
+ expect(schema_parser.schema_for_url_and_request_method).not_to(
19
+ be_nil,
20
+ 'http method for url not documented'
21
+ )
16
22
  end
17
23
 
18
24
  it 'has all required request query parameters' do
19
25
  schema_parser.openapi_required_query_string_params.each do |openapi_param|
20
- expect(schema_parser.request_params).to include(openapi_param)
26
+ expect(schema_parser.request_params).to(
27
+ include(openapi_param),
28
+ 'missing required request query parameters'
29
+ )
21
30
  end
22
31
  end
23
32
 
24
33
  it 'has all required request path parameters' do
25
34
  schema_parser.openapi_required_path_params.each do |openapi_param|
26
- expect(schema_parser.request_path_params).to include(openapi_param)
35
+ expect(schema_parser.request_path_params).to(
36
+ include(openapi_param),
37
+ 'missing required request path parameters'
38
+ )
27
39
  end
28
40
  end
29
41
 
30
42
  it 'has all required request form data parameters' do
31
43
  schema_parser.openapi_required_form_data_params.each do |openapi_param|
32
- expect(schema_parser.request_params).to include(openapi_param)
44
+ expect(schema_parser.request_params).to(
45
+ include(openapi_param),
46
+ 'missing required request form data parameters'
47
+ )
33
48
  end
34
49
  end
35
50
 
36
51
  it 'does not allow undocumented request path parameters' do
37
52
  schema_parser.request_path_params.each do |request_param|
38
- expect(schema_parser.openapi_path_params).to include(request_param)
53
+ expect(schema_parser.openapi_path_params).to(
54
+ include(request_param),
55
+ "#{request_param} is an undocumented request path parameter"
56
+ )
39
57
  end
40
58
  end
41
59
 
42
60
  it 'does not allow undocumented request parameters' do
43
61
  schema_parser.request_params.each do |request_param|
44
- expect(schema_parser.openapi_request_params).to include(request_param)
62
+ expect(schema_parser.openapi_request_params).to(
63
+ include(request_param),
64
+ "#{request_param} is an undocumented request parameter"
65
+ )
45
66
  end
46
67
  end
47
68
 
48
69
  it 'matches an allowed http response status' do
49
- expect(schema_parser.schema_for_url_and_request_method_and_response_status).not_to be_nil
70
+ expect(schema_parser.schema_for_url_and_request_method_and_response_status).not_to(
71
+ be_nil,
72
+ 'http response status not documented'
73
+ )
50
74
  end
51
75
  it 'matches the response schema' do
52
76
  response_schema = schema_parser.schema_for_url_and_request_method_and_response_status
@@ -60,7 +84,7 @@ module OpenApi
60
84
  response_schema
61
85
  end
62
86
 
63
- expect(results).to be_truthy
87
+ expect(results).to be_truthy, 'response does not match documented schema'
64
88
  end
65
89
  end
66
90
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenApi
4
4
  module RSpec
5
- VERSION = '0.1.5'
5
+ VERSION = '0.1.6'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_api-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hansen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -186,7 +186,7 @@ extensions: []
186
186
  extra_rdoc_files: []
187
187
  files:
188
188
  - ".gitignore"
189
- - ".reek"
189
+ - ".reek.yml"
190
190
  - ".rspec"
191
191
  - ".rubocop.yml"
192
192
  - ".rubocop_todo.yml"
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  requirements: []
230
230
  rubyforge_project:
231
- rubygems_version: 2.7.6
231
+ rubygems_version: 2.7.7
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: RSpec matchers and shared examples for OpenApi
data/.reek DELETED
@@ -1,59 +0,0 @@
1
- ---
2
- DuplicateMethodCall:
3
- exclude:
4
- - OpenApi::RSpec::SchemaParser#deep_body_keys
5
- - OpenApi::RSpec::SchemaParser#get_deep_keys
6
- - OpenApi::RSpec::SchemaParser#initialize
7
- - OpenApi::RSpec::SchemaParser#openapi_body_params
8
- - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_and_response_status
9
- FeatureEnvy:
10
- exclude:
11
- - OpenApi::RSpec::SchemaParser#deep_body_keys
12
- - OpenApi::RSpec::SchemaParser#get_deep_keys
13
- - OpenApi::RSpec::SchemaParser#openapi_required_form_data_params
14
- - OpenApi::RSpec::SchemaParser#openapi_required_path_params
15
- - OpenApi::RSpec::SchemaParser#openapi_required_query_string_params
16
- NestedIterators:
17
- exclude:
18
- - OpenApi::RSpec::SchemaParser#deep_body_keys
19
- - OpenApi::RSpec::SchemaParser#get_deep_keys
20
- - OpenApi::RSpec::SchemaParser#initialize
21
- - OpenApi::RSpec::SchemaParser#openapi_body_params
22
- TooManyInstanceVariables:
23
- exclude:
24
- - OpenApi::RSpec::SchemaParser
25
- TooManyMethods:
26
- exclude:
27
- - OpenApi::RSpec::SchemaParser
28
- TooManyStatements:
29
- exclude:
30
- - initialize
31
- - OpenApi::RSpec::SchemaParser#deep_body_keys
32
- - OpenApi::RSpec::SchemaParser#get_deep_keys
33
- - OpenApi::RSpec::SchemaParser#openapi_body_params
34
- UncommunicativeVariableName:
35
- exclude:
36
- - OpenApi::RSpec::SchemaParser#get_deep_keys
37
- - OpenApi::RSpec::SchemaParser#initialize
38
- - OpenApi::RSpec::SchemaParser#openapi_body_params
39
- - OpenApi::RSpec::SchemaParser#openapi_form_data_params
40
- - OpenApi::RSpec::SchemaParser#openapi_path_params
41
- - OpenApi::RSpec::SchemaParser#openapi_query_string_params
42
- - OpenApi::RSpec::SchemaParser#openapi_required_form_data_params
43
- - OpenApi::RSpec::SchemaParser#openapi_required_path_params
44
- - OpenApi::RSpec::SchemaParser#openapi_required_query_string_params
45
- - OpenApi::RSpec::SchemaParser#request_path_params
46
- - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_body_parameters
47
- - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_form_data_parameters
48
- - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_path_parameters
49
- - OpenApi::RSpec::SchemaParser#schema_for_url_and_request_method_query_string_parameters
50
- UtilityFunction:
51
- exclude:
52
- - OpenApi::RSpec::SchemaParser#has_documented_param_in_openapi_url_fragments
53
- - OpenApi::RSpec::SchemaParser#openapi_url_fragment_name
54
-
55
- IrresponsibleModule:
56
- enabled: false
57
-
58
- exclude_paths:
59
- - vendor/bundle