rspec-rails-api 0.9.2 → 0.10.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36fe79a8d00eac7bac5fcf841239e39a73ff8a7c47db046bbe18590e0db4085a
4
- data.tar.gz: 59e955a181a272b105015901e94268fab2cd67c0119f7cbcef8cc153a8e47450
3
+ metadata.gz: 202f4f620ba4cca5a1409e077c6a57d3f28f573f21be929c2542d05cb193b28b
4
+ data.tar.gz: aa901e77a066cba12e12005cf63d70b84fb2c216cc8cc3d8d7d1f754a20c3b58
5
5
  SHA512:
6
- metadata.gz: e164de7f7023e524ce047c87883d569e82559c0fbfc7311bbdfff4b0fbefa68aceaf653ffc3d7232c750092cdd17d75c1a57837c10c3c34fecf8d650f2507578
7
- data.tar.gz: 21cef61f13ceeb836165e4779ae0b191577ab31d78ad8677fc53afdbdb10a5880f7a8b6dc557b25d4b9bf3b6e95c8eadae3c9090a58d8cb3f05edda2ee5a7951
6
+ metadata.gz: 014a711a59dc4f561e1c0a4a1f0580c17d8d3218c9eb25c97fa93a0ca89777b008cf0dc1fa28edb92db7d532f047f7b71392365d93c54a5c7dd8a1b0ed09f5d6
7
+ data.tar.gz: f5d0f69d35f2f2a80302d969bc3efc4939d1642268b3a01b2afadd814c4c68af7ec1854f57863ac1d9fb7496ee551587d03a4eeed2b74ac5468f0ffc1eeb2bb3
data/.gitlab-ci.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- image: ruby:3.1
2
+ image: ruby:3.3
3
3
 
4
4
  stages:
5
5
  - prepare
data/.rubocop.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  ---
2
- require:
2
+ plugins:
3
3
  - rubocop-performance
4
4
  - rubocop-rake
5
5
  - rubocop-rspec
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 3.1
8
+ TargetRubyVersion: 3.3
9
9
  Exclude:
10
10
  - dummy/**/*
11
11
  - vendor/bundle/**/*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.3.14
data/CHANGELOG.md CHANGED
@@ -18,6 +18,17 @@ Maintenance, in case of rework, dependencies change
18
18
 
19
19
  ## [Unreleased]
20
20
 
21
+ ## [0.10.0] - 2026-11-20
22
+
23
+ ### Changed
24
+
25
+ - Ruby 3.3.14 is the minimum ruby version supported
26
+ - The gem is now developped against Rails 8.1; previous versions _may_ still work with no guarantee
27
+
28
+ ### Fixed
29
+
30
+ - Corrected documentation and example for configuration of `redact_responses` option.
31
+
21
32
  ## [0.9.2] - 2026-06-14
22
33
 
23
34
  ### Changed
data/Gemfile CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source 'https://rubygems.org', cooldown: 7
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in rspec-rails-api.gemspec
8
8
  gemspec
9
9
 
10
- gem 'activesupport', '~> 7.2'
10
+ gem 'activesupport', '~> 8.1'
11
11
  gem 'bundler'
12
12
  gem 'byebug'
13
13
  gem 'json-schema'
data/Gemfile.lock CHANGED
@@ -1,103 +1,119 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-rails-api (0.9.2)
4
+ rspec-rails-api (0.10.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activesupport (7.2.1)
9
+ activesupport (8.1.4.1)
10
10
  base64
11
11
  bigdecimal
12
12
  concurrent-ruby (~> 1.0, >= 1.3.1)
13
13
  connection_pool (>= 2.2.5)
14
14
  drb
15
15
  i18n (>= 1.6, < 2)
16
+ json
16
17
  logger (>= 1.4.2)
17
18
  minitest (>= 5.1)
18
19
  securerandom (>= 0.3)
19
20
  tzinfo (~> 2.0, >= 2.0.5)
20
- addressable (2.8.7)
21
- public_suffix (>= 2.0.2, < 7.0)
22
- ast (2.4.2)
23
- base64 (0.2.0)
24
- bigdecimal (3.1.8)
25
- byebug (11.1.3)
26
- concurrent-ruby (1.3.4)
27
- connection_pool (2.4.1)
28
- diff-lcs (1.5.1)
29
- docile (1.4.1)
30
- drb (2.2.1)
31
- i18n (1.14.6)
21
+ uri (>= 0.13.1)
22
+ addressable (2.9.2)
23
+ public_suffix (>= 2.0.2, < 8.0)
24
+ ast (2.4.3)
25
+ base64 (0.3.0)
26
+ bigdecimal (4.1.3)
27
+ byebug (13.0.0)
28
+ reline (>= 0.6.0)
29
+ concurrent-ruby (1.3.8)
30
+ connection_pool (3.0.3)
31
+ diff-lcs (1.6.2)
32
+ drb (2.2.3)
33
+ i18n (1.15.2)
32
34
  concurrent-ruby (~> 1.0)
33
- json (2.7.2)
34
- json-schema (5.1.1)
35
+ io-console (0.9.5)
36
+ json (3.1.0)
37
+ json-schema (6.2.1)
35
38
  addressable (~> 2.8)
36
- bigdecimal (~> 3.1)
37
- language_server-protocol (3.17.0.3)
38
- logger (1.6.1)
39
- minitest (5.25.1)
40
- parallel (1.26.3)
41
- parser (3.3.5.0)
39
+ bigdecimal (>= 3.1, < 5)
40
+ language_server-protocol (3.17.0.6)
41
+ lint_roller (1.1.0)
42
+ logger (1.7.0)
43
+ minitest (6.1.0)
44
+ drb (~> 2.0)
45
+ prism (>= 1.5, < 3)
46
+ parallel (2.3.0)
47
+ parser (3.3.14.0)
42
48
  ast (~> 2.4.1)
43
49
  racc
44
- public_suffix (6.0.1)
50
+ prism (2.1.0)
51
+ prism (2.1.0-x86_64-linux-gnu)
52
+ public_suffix (7.0.5)
45
53
  racc (1.8.1)
46
- rack (3.1.7)
54
+ rack (3.2.8)
47
55
  rainbow (3.1.1)
48
56
  rake (10.5.0)
49
- regexp_parser (2.9.2)
50
- rspec (3.13.0)
57
+ regexp_parser (2.13.4)
58
+ reline (0.7.0)
59
+ io-console (~> 0.5)
60
+ rspec (3.13.2)
51
61
  rspec-core (~> 3.13.0)
52
62
  rspec-expectations (~> 3.13.0)
53
63
  rspec-mocks (~> 3.13.0)
54
- rspec-core (3.13.1)
64
+ rspec-core (3.13.7)
55
65
  rspec-support (~> 3.13.0)
56
- rspec-expectations (3.13.3)
66
+ rspec-expectations (3.13.6)
57
67
  diff-lcs (>= 1.2.0, < 2.0)
58
68
  rspec-support (~> 3.13.0)
59
- rspec-mocks (3.13.1)
69
+ rspec-mocks (3.13.9)
60
70
  diff-lcs (>= 1.2.0, < 2.0)
61
71
  rspec-support (~> 3.13.0)
62
- rspec-support (3.13.1)
63
- rubocop (1.66.1)
64
- json (~> 2.3)
65
- language_server-protocol (>= 3.17.0)
66
- parallel (~> 1.10)
72
+ rspec-support (3.13.8)
73
+ rubocop (1.92.3)
74
+ json (>= 2.3)
75
+ language_server-protocol (~> 3.17.0.2)
76
+ lint_roller (~> 1.1.0)
77
+ parallel (>= 1.10)
67
78
  parser (>= 3.3.0.2)
68
79
  rainbow (>= 2.2.2, < 4.0)
69
- regexp_parser (>= 2.4, < 3.0)
70
- rubocop-ast (>= 1.32.2, < 2.0)
80
+ regexp_parser (>= 2.11.3, < 3.0)
81
+ rubocop-ast (>= 1.49.0, < 2.0)
71
82
  ruby-progressbar (~> 1.7)
72
- unicode-display_width (>= 2.4.0, < 3.0)
73
- rubocop-ast (1.32.3)
74
- parser (>= 3.3.1.0)
75
- rubocop-performance (1.22.1)
76
- rubocop (>= 1.48.1, < 2.0)
77
- rubocop-ast (>= 1.31.1, < 2.0)
78
- rubocop-rake (0.6.0)
79
- rubocop (~> 1.0)
80
- rubocop-rspec (3.0.5)
81
- rubocop (~> 1.61)
83
+ unicode-display_width (>= 2.4.0, < 4.0)
84
+ rubocop-ast (1.53.0)
85
+ ast (~> 2.4)
86
+ parser (>= 3.3.7.2)
87
+ prism (>= 1.7)
88
+ racc
89
+ rubocop-performance (1.27.0)
90
+ lint_roller (~> 1.1)
91
+ rubocop (>= 1.89.0, < 2.0)
92
+ rubocop-ast (>= 1.47.1, < 2.0)
93
+ rubocop-rake (0.7.1)
94
+ lint_roller (~> 1.1)
95
+ rubocop (>= 1.72.1)
96
+ rubocop-rspec (3.10.2)
97
+ lint_roller (~> 1.1)
98
+ regexp_parser (>= 2.0)
99
+ rubocop (~> 1.86, >= 1.86.2)
82
100
  ruby-progressbar (1.13.0)
83
- securerandom (0.3.1)
84
- simplecov (0.22.0)
85
- docile (~> 1.1)
86
- simplecov-html (~> 0.11)
87
- simplecov_json_formatter (~> 0.1)
88
- simplecov-html (0.13.1)
89
- simplecov_json_formatter (0.1.4)
101
+ securerandom (0.4.1)
102
+ simplecov (1.3.2)
90
103
  tzinfo (2.0.6)
91
104
  concurrent-ruby (~> 1.0)
92
- unicode-display_width (2.6.0)
93
- yard (0.9.37)
105
+ unicode-display_width (3.3.0)
106
+ unicode-emoji (~> 4.3)
107
+ unicode-emoji (4.3.0)
108
+ uri (1.1.2)
109
+ yard (0.9.45)
94
110
 
95
111
  PLATFORMS
96
112
  ruby
97
113
  x86_64-linux
98
114
 
99
115
  DEPENDENCIES
100
- activesupport (~> 7.2)
116
+ activesupport (~> 8.1)
101
117
  bundler
102
118
  byebug
103
119
  json-schema
data/README.md CHANGED
@@ -119,9 +119,10 @@ renderer.api_version = '1'
119
119
  # type: 'http',
120
120
  # scheme: 'bearer'
121
121
  #
122
- # Declare keys whose values should be filtered in responses.
123
- # renderer.redact_responses entity_name: { key: 'REDACTED' },
124
- # other_entity: { other_key: ['REDACTED'] }
122
+ # Declare keys whose values should be filtered in responses.
123
+ # Keys are strings and not symbols, as they should match the JSON content.
124
+ # renderer.redact_responses entity_name: { 'key' => 'REDACTED' },
125
+ # other_entity: { 'other_key' => ['REDACTED'] }
125
126
 
126
127
 
127
128
  # We need to merge each context metadata so we can reference to them to build the final file
@@ -168,7 +168,7 @@ module RSpec
168
168
  metadata[:rra].add_expectations(expect_one, expect_many, content_type: with_content_type)
169
169
  metadata[:rra_current_example] = metadata[:rra].current_example
170
170
 
171
- describe "->#{test_only ? ' test' : ''} #{status_code} - #{description}" do
171
+ describe "->#{' test' if test_only} #{status_code} - #{description}" do
172
172
  execute_for_code_block(block)
173
173
  end
174
174
  end
@@ -13,7 +13,7 @@ RSpec::Matchers.define :have_many do |expected|
13
13
  actual = RSpec::Rails::Api::Utils.hash_from_response actual
14
14
 
15
15
  raise "Response is not an array: #{actual.class}" unless actual.is_a? Array
16
- raise 'Response has no item to compare with' unless actual.count.positive?
16
+ raise 'Response has no item to compare with' if actual.empty?
17
17
 
18
18
  @errors = RSpec::Rails::Api::Validator.validate_array actual, expected
19
19
 
@@ -179,7 +179,7 @@ module RSpec
179
179
  #
180
180
  # @return [void]
181
181
  #
182
- # rubocop:disable Layout/LineLength
182
+ # rubocop:disable-next Layout/LineLength
183
183
  def add_status_code(status_code, description)
184
184
  check_current_context :resource, :url, :method
185
185
 
@@ -189,7 +189,6 @@ module RSpec
189
189
  example: { response: nil })
190
190
  @current_code = status_code
191
191
  end
192
- # rubocop:enable Layout/LineLength
193
192
 
194
193
  ##
195
194
  # Gets the current example
@@ -217,7 +216,7 @@ module RSpec
217
216
  check_current_context :resource, :url, :method, :code
218
217
  none = !many && !one
219
218
 
220
- # rubocop:disable Layout/LineLength
219
+ # rubocop:disable-next Layout/LineLength
221
220
  Utils.deep_set(@resources,
222
221
  [@current_resource, 'paths', @current_url, 'actions', @current_method, 'statuses', @current_code, 'expectations'],
223
222
  {
@@ -226,7 +225,6 @@ module RSpec
226
225
  none: none,
227
226
  content_type: content_type,
228
227
  })
229
- # rubocop:enable Layout/LineLength
230
228
  end
231
229
 
232
230
  ##
@@ -239,7 +237,7 @@ module RSpec
239
237
  # @param path_params [Hash, nil] Used path parameters
240
238
  # @param params [Hash, nil] Used body parameters
241
239
  #
242
- # rubocop:disable Metrics/ParameterLists
240
+ # rubocop:disable-next Metrics/ParameterLists
243
241
  def add_request_example(url: nil, action: nil, status_code: nil, response: nil, path_params: nil, params: nil)
244
242
  resource = nil
245
243
  @resources.each do |key, res|
@@ -254,7 +252,6 @@ module RSpec
254
252
  params: params,
255
253
  response: response)
256
254
  end
257
- # rubocop:enable Metrics/ParameterLists
258
255
 
259
256
  ##
260
257
  # @return [Hash] Hash representation of the metadata
@@ -319,7 +316,7 @@ module RSpec
319
316
 
320
317
  out[:properties][name] = fill_request_param field
321
318
  end
322
- out[:required] = required if required.count.positive?
319
+ out[:required] = required unless required.empty?
323
320
  out
324
321
  end
325
322
 
@@ -159,7 +159,7 @@ module RSpec
159
159
  #
160
160
  # @return [void]
161
161
  def extract_security
162
- return unless @api_security.keys.count.positive?
162
+ return if @api_security.keys.empty?
163
163
 
164
164
  @api_components['securitySchemes'] = @api_security
165
165
  end
@@ -291,13 +291,13 @@ items: { '$ref' => "#/components/schemas/#{field.attributes}" } }
291
291
  #
292
292
  # FIXME: Rename "action_config" to "action"
293
293
  # FIXME: Rename "parameters" to "path_parameters"
294
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
294
+ # rubocop:disable-next Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
295
295
  def process_action(resource: nil, path: nil, path_config: nil, action_config: nil, parameters: nil)
296
296
  responses = {}
297
297
  request_body = nil
298
298
 
299
299
  if %i[post put
300
- patch].include?(action_config) && path_config[:actions][action_config][:params].keys.count.positive?
300
+ patch].include?(action_config) && !path_config[:actions][action_config][:params].keys.empty?
301
301
  schema = path_config[:actions][action_config][:params]
302
302
  schema_ref = escape_operation_id("#{action_config}_#{path}")
303
303
  examples = process_examples(path_config[:actions][action_config][:statuses])
@@ -333,7 +333,6 @@ items: { '$ref' => "#/components/schemas/#{field.attributes}" } }
333
333
 
334
334
  action
335
335
  end
336
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
337
336
 
338
337
  ##
339
338
  # Processes a request body from metadata
@@ -462,7 +461,7 @@ items: { '$ref' => "#/components/schemas/#{field.attributes}" } }
462
461
  end
463
462
 
464
463
  def global_entities
465
- return if RSpec::Rails::Api::Metadata.entities.keys.count.zero?
464
+ return if RSpec::Rails::Api::Metadata.entities.keys.empty?
466
465
 
467
466
  @api_components[:schemas] = {}
468
467
 
@@ -19,7 +19,7 @@ module RSpec
19
19
  def deep_set(hash, path, value)
20
20
  raise 'path should be an array' unless path.is_a? Array
21
21
 
22
- return value if path.count.zero?
22
+ return value if path.empty?
23
23
 
24
24
  current_key = path.shift.to_s.to_sym
25
25
  hash[current_key] = {} unless hash[current_key].is_a?(Hash)
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Rails
5
5
  module Api
6
- VERSION = '0.9.2'
6
+ VERSION = '0.10.0'
7
7
  end
8
8
  end
9
9
  end
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
34
  spec.require_paths = ['lib']
35
35
 
36
- spec.required_ruby_version = '>= 3.1.2'
36
+ spec.required_ruby_version = '>= 3.3.14'
37
37
  end
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.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Tancoigne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-14 00:00:00.000000000 Z
11
+ date: 2026-11-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Create acceptance tests to check the Rails API responses and generate
@@ -24,14 +24,12 @@ files:
24
24
  - ".rspec"
25
25
  - ".rubocop.yml"
26
26
  - ".ruby-version"
27
- - ".travis.yml"
28
27
  - CHANGELOG.md
29
28
  - CODE_OF_CONDUCT.md
30
29
  - Gemfile
31
30
  - Gemfile.lock
32
31
  - LICENSE.txt
33
32
  - README.md
34
- - Rakefile
35
33
  - bin/console
36
34
  - bin/setup
37
35
  - lib/rspec/rails/api/dsl/example.rb
@@ -62,7 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
60
  requirements:
63
61
  - - ">="
64
62
  - !ruby/object:Gem::Version
65
- version: 3.1.2
63
+ version: 3.3.14
66
64
  required_rubygems_version: !ruby/object:Gem::Requirement
67
65
  requirements:
68
66
  - - ">="
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.1
7
- before_install: gem install bundler -v 1.17.0
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'yard'
6
-
7
- RSpec::Core::RakeTask.new(:spec)
8
-
9
- task default: :spec
10
-
11
- YARD::Rake::YardocTask.new