rspec-rails-api 0.2.2 → 0.2.3

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
- SHA256:
3
- metadata.gz: df99a2088657641a87ec55c6159cdf7973d75863718f94aebef6cc70d7b4ac95
4
- data.tar.gz: 4bf341e1fc70d6dfe760a531e43aec6c4c8002b3c1000fe83d1b2ae3cac3f3a0
2
+ SHA1:
3
+ metadata.gz: '078c84277a76bd17ba55a74621786e39a5fc016c'
4
+ data.tar.gz: 8d9cb8744200020c3dbefb0936f56c761ac47d59
5
5
  SHA512:
6
- metadata.gz: 42b42ba732de1383324dde829463f6a042289f184a959a9dc1c8ff727d8fd56699f7e97f40d215f184f724249517be826f5de4a66a5e684593a166ee25843624
7
- data.tar.gz: 2daa6738912fcf4192e7c155a6744400420cabb5b1422de6dca77d34ece4dee59528d228b85af52fed0e5eaa17aebb4d14b06ca46e913a81c46318c8b11b67da
6
+ metadata.gz: 1831e37f21cde2aed080f9bc9f0e1b77e54a982cd7a75d8f78acdc0fd37159df82efae1d24c2fb2fa0d60566a0f753a5e1d7e03d98a89badb2aff0d8635153a4
7
+ data.tar.gz: 232482ef059cc827136d4d17b23fec9fe3baa113bf9c718c8573b18f9c6493d6f8cbba6bdb61e4b36651ab401107da450859332230215d97e7daa077a7b50114
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@ require:
3
3
  - rubocop-performance
4
4
 
5
5
  AllCops:
6
+ TargetRubyVersion: 2.3
6
7
  Exclude:
7
8
  - dummy/**/*
8
9
  - vendor/bundle/**/*
@@ -17,11 +18,11 @@ Metrics/LineLength:
17
18
  Exclude:
18
19
  - spec/**/*_spec.rb
19
20
 
20
- Naming/UncommunicativeMethodParamName:
21
+ Naming/MethodParameterName:
21
22
  AllowedNames:
22
23
  - of
23
24
 
24
- Layout/AlignHash:
25
+ Layout/HashAlignment:
25
26
  EnforcedColonStyle: table
26
27
  EnforcedHashRocketStyle: table
27
28
 
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## Not released
5
5
 
6
+ ## 0.2.3 - 2019-12-04
7
+
8
+ ### Improved
9
+
10
+ - Generated Swagger file now use the payloads of POST/PATCH/PUT requests.
11
+ - Minimum Ruby version is now specified: Ruby 2.3.3.
12
+
6
13
  ## 0.2.1/0.2.2 - 2019-11-03
7
14
 
8
15
  _Version 0.2.1 was released and yanked by mistake. Version 0.2.2 is the exact
@@ -142,7 +142,8 @@ module RSpec
142
142
  if path_config[:actions][action_config][:params].keys.count.positive?
143
143
  schema = path_config[:actions][action_config][:params]
144
144
  schema_ref = escape_operation_id("#{action_config}_#{path}")
145
- request_body = process_request_body schema: schema, ref: schema_ref
145
+ examples = process_examples(path_config[:actions][action_config][:statuses])
146
+ request_body = process_request_body schema: schema, ref: schema_ref, examples: examples
146
147
  end
147
148
  end
148
149
 
@@ -166,14 +167,15 @@ module RSpec
166
167
  end
167
168
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
168
169
 
169
- def process_request_body(schema: nil, ref: nil)
170
+ def process_request_body(schema: nil, ref: nil, examples: {})
170
171
  Utils.deep_set @api_components, "schemas.#{ref}", schema
171
172
  {
172
173
  # description: '',
173
174
  required: true,
174
175
  content: {
175
176
  'application/json' => {
176
- schema: { '$ref' => "#/components/schemas/#{ref}" },
177
+ schema: { '$ref' => "#/components/schemas/#{ref}" },
178
+ examples: examples,
177
179
  },
178
180
  },
179
181
  }
@@ -184,7 +186,7 @@ module RSpec
184
186
  description: status_config[:description],
185
187
  }
186
188
 
187
- return response unless status.to_s != '204' && content # No content
189
+ return response if status.to_s == '204' && content # No content
188
190
 
189
191
  response[:content] = {
190
192
  'application/json': {
@@ -195,6 +197,19 @@ module RSpec
195
197
  response
196
198
  end
197
199
 
200
+ def process_examples(statuses)
201
+ request_examples = {}
202
+
203
+ statuses.each do |code, request|
204
+ request_examples[code] = {
205
+ summary: "Example for a #{code} code",
206
+ value: request[:example][:params],
207
+ }
208
+ end
209
+
210
+ request_examples
211
+ end
212
+
198
213
  def path_with_params(string)
199
214
  string.gsub(/(?::(\w*))/) do |e|
200
215
  "{#{e.sub(':', '')}}"
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Rails
5
5
  module Api
6
- VERSION = '0.2.2'
6
+ VERSION = '0.2.3'
7
7
  end
8
8
  end
9
9
  end
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ['lib']
34
34
 
35
+ spec.required_ruby_version = '>= 2.3.3'
36
+
35
37
  spec.add_development_dependency 'activesupport', '>= 5.2'
36
38
  spec.add_development_dependency 'bundler', '~> 1.17'
37
39
  spec.add_development_dependency 'byebug'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Tancoigne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-03 00:00:00.000000000 Z
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: 2.3.3
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - ">="
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  version: '0'
179
179
  requirements: []
180
180
  rubyforge_project:
181
- rubygems_version: 2.7.6
181
+ rubygems_version: 2.5.2
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: Tests standard Rails API responses and generate doc