rspec-rails-api 0.6.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +6 -5
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +30 -1
- data/Gemfile +13 -0
- data/Gemfile.lock +60 -49
- data/README.md +8 -2
- data/lib/rspec/rails/api/dsl/example.rb +4 -3
- data/lib/rspec/rails/api/dsl/example_group.rb +20 -19
- data/lib/rspec/rails/api/metadata.rb +14 -4
- data/lib/rspec/rails/api/open_api_renderer.rb +4 -9
- data/lib/rspec/rails/api/validator.rb +1 -1
- data/lib/rspec/rails/api/version.rb +1 -1
- data/rspec-rails-api.gemspec +1 -14
- metadata +5 -173
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2d9a9837952843bbacdc2b355dd3e1625060a114f609cf1f3396e33b5132d2
|
4
|
+
data.tar.gz: f9f914d1a513f6a6453477cfa68f79b0842f7a6002a5ce55a97bd7705d068749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4514ec049d648ccd1ad00a441a0f1dd208f53b7e1a769efcbb46e8feb0b086cf0b336da138b643986292f1f04d0afe0827f2784f5faa2e7cb5ed4746d611c0d
|
7
|
+
data.tar.gz: a9c1959eaa5596f6b1501fe11f0a325481efa074b6163edbd7f922bf423130f3171f19c3158d317514a54adeea6ffb29f9b8fcc4287e3c25165a217ec0397f37
|
data/.gitlab-ci.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
---
|
2
|
-
image: ruby:
|
2
|
+
image: ruby:3.1
|
3
3
|
|
4
4
|
stages:
|
5
5
|
- prepare
|
@@ -8,7 +8,8 @@ stages:
|
|
8
8
|
bundle:
|
9
9
|
stage: prepare
|
10
10
|
script:
|
11
|
-
-
|
11
|
+
- ruby --version
|
12
|
+
- bundle install --path='vendor/bundle' --frozen
|
12
13
|
artifacts:
|
13
14
|
untracked: true
|
14
15
|
expire_in: 1 hour
|
@@ -22,7 +23,7 @@ bundle:
|
|
22
23
|
rubocop:
|
23
24
|
stage: test
|
24
25
|
script:
|
25
|
-
- bundle install --path='vendor/bundle'
|
26
|
+
- bundle install --path='vendor/bundle' --frozen
|
26
27
|
- bundle exec rubocop
|
27
28
|
dependencies:
|
28
29
|
- bundle
|
@@ -30,7 +31,7 @@ rubocop:
|
|
30
31
|
rspec:
|
31
32
|
stage: test
|
32
33
|
script:
|
33
|
-
- bundle install --path='vendor/bundle'
|
34
|
+
- bundle install --path='vendor/bundle' --frozen
|
34
35
|
- bundle exec rspec
|
35
36
|
dependencies:
|
36
37
|
- bundle
|
@@ -39,6 +40,6 @@ dummy:
|
|
39
40
|
stage: test
|
40
41
|
script:
|
41
42
|
- cd dummy
|
42
|
-
- bundle install --path='vendor/bundle'
|
43
|
+
- bundle install --path='vendor/bundle' --frozen
|
43
44
|
- bundle exec rubocop
|
44
45
|
- bundle exec rspec
|
data/.rubocop.yml
CHANGED
@@ -5,7 +5,7 @@ require:
|
|
5
5
|
- rubocop-rspec
|
6
6
|
|
7
7
|
AllCops:
|
8
|
-
TargetRubyVersion:
|
8
|
+
TargetRubyVersion: 3.1
|
9
9
|
Exclude:
|
10
10
|
- dummy/**/*
|
11
11
|
- vendor/bundle/**/*
|
@@ -29,6 +29,9 @@ Layout/HashAlignment:
|
|
29
29
|
EnforcedColonStyle: table
|
30
30
|
EnforcedHashRocketStyle: table
|
31
31
|
|
32
|
+
Style/HashSyntax:
|
33
|
+
EnforcedShorthandSyntax: never
|
34
|
+
|
32
35
|
Style/TrailingCommaInArrayLiteral:
|
33
36
|
EnforcedStyleForMultiline: comma
|
34
37
|
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.2
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,35 @@ Maintenance, in case of rework, dependencies change
|
|
18
18
|
|
19
19
|
## [Unreleased]
|
20
20
|
|
21
|
+
## [0.8.0] - 2024-09-28
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- Support for custom expected content types (as long as it's JSON): use `RSpec::Rails::Api::Metadata.default_expected_content_type=`
|
26
|
+
in the spec helper, or on specific tests: `for_code 200, expect_one: :string, with_content_type: 'application/json+custom; charset=utf-8' do |url|`
|
27
|
+
|
28
|
+
### Changed
|
29
|
+
|
30
|
+
- [BREAKING] Target ruby 3.1.2 (debian 12 default)
|
31
|
+
|
32
|
+
## [0.7.0] - 2024-01-24
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- [BREAKING] Don't add `name` property in security schemes that should not have one.
|
37
|
+
Only `type: :apiKey` should have one, so the `name` argument of `add_security_scheme` has been removed. Specify it
|
38
|
+
when it is required/accepted only.
|
39
|
+
```rb
|
40
|
+
# Change:
|
41
|
+
# ref name schema
|
42
|
+
renderer.add_security_scheme :basic, "Basic authentication", { type: "http", scheme: "basic" }
|
43
|
+
renderer.add_security_scheme :api_key, "API key authentication", { type: "apiKey", in: "header" }
|
44
|
+
# To:
|
45
|
+
# ref schema
|
46
|
+
renderer.add_security_scheme :basic, type: "http", scheme: "basic"
|
47
|
+
renderer.add_security_scheme :api_key, name: "API key authentication", type: "apiKey", in: "header"
|
48
|
+
```
|
49
|
+
|
21
50
|
## [0.6.3] - 2024-01-24
|
22
51
|
|
23
52
|
### Fixed
|
@@ -83,7 +112,7 @@ Maintenance, in case of rework, dependencies change
|
|
83
112
|
prefix
|
84
113
|
|
85
114
|
### Fixed
|
86
|
-
|
115
|
+
|
87
116
|
- Fixed an error when an object is defined with an attribute named `type`.
|
88
117
|
|
89
118
|
## [0.4.0] - 2021-12-19
|
data/Gemfile
CHANGED
@@ -6,3 +6,16 @@ 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
|
+
|
10
|
+
gem 'activesupport', '~> 7.2'
|
11
|
+
gem 'bundler'
|
12
|
+
gem 'byebug'
|
13
|
+
gem 'rack'
|
14
|
+
gem 'rake', '~> 10.0'
|
15
|
+
gem 'rspec', '~> 3.0'
|
16
|
+
gem 'rubocop'
|
17
|
+
gem 'rubocop-performance'
|
18
|
+
gem 'rubocop-rake'
|
19
|
+
gem 'rubocop-rspec'
|
20
|
+
gem 'simplecov'
|
21
|
+
gem 'yard'
|
data/Gemfile.lock
CHANGED
@@ -1,86 +1,97 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-rails-api (0.
|
4
|
+
rspec-rails-api (0.8.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activesupport (
|
10
|
-
|
9
|
+
activesupport (7.2.1)
|
10
|
+
base64
|
11
|
+
bigdecimal
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
13
|
+
connection_pool (>= 2.2.5)
|
14
|
+
drb
|
11
15
|
i18n (>= 1.6, < 2)
|
16
|
+
logger (>= 1.4.2)
|
12
17
|
minitest (>= 5.1)
|
13
|
-
|
14
|
-
|
18
|
+
securerandom (>= 0.3)
|
19
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
15
20
|
ast (2.4.2)
|
21
|
+
base64 (0.2.0)
|
22
|
+
bigdecimal (3.1.8)
|
16
23
|
byebug (11.1.3)
|
17
|
-
concurrent-ruby (1.
|
18
|
-
|
19
|
-
|
20
|
-
|
24
|
+
concurrent-ruby (1.3.4)
|
25
|
+
connection_pool (2.4.1)
|
26
|
+
diff-lcs (1.5.1)
|
27
|
+
docile (1.4.1)
|
28
|
+
drb (2.2.1)
|
29
|
+
i18n (1.14.6)
|
21
30
|
concurrent-ruby (~> 1.0)
|
22
|
-
json (2.
|
23
|
-
|
24
|
-
|
25
|
-
|
31
|
+
json (2.7.2)
|
32
|
+
language_server-protocol (3.17.0.3)
|
33
|
+
logger (1.6.1)
|
34
|
+
minitest (5.25.1)
|
35
|
+
parallel (1.26.3)
|
36
|
+
parser (3.3.5.0)
|
26
37
|
ast (~> 2.4.1)
|
27
|
-
|
38
|
+
racc
|
39
|
+
racc (1.8.1)
|
40
|
+
rack (3.1.7)
|
28
41
|
rainbow (3.1.1)
|
29
42
|
rake (10.5.0)
|
30
|
-
regexp_parser (2.
|
31
|
-
|
32
|
-
|
33
|
-
rspec-
|
34
|
-
rspec-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
rspec-expectations (3.12.1)
|
43
|
+
regexp_parser (2.9.2)
|
44
|
+
rspec (3.13.0)
|
45
|
+
rspec-core (~> 3.13.0)
|
46
|
+
rspec-expectations (~> 3.13.0)
|
47
|
+
rspec-mocks (~> 3.13.0)
|
48
|
+
rspec-core (3.13.1)
|
49
|
+
rspec-support (~> 3.13.0)
|
50
|
+
rspec-expectations (3.13.3)
|
39
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
52
|
+
rspec-support (~> 3.13.0)
|
53
|
+
rspec-mocks (3.13.1)
|
42
54
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-support (3.
|
45
|
-
rubocop (1.
|
55
|
+
rspec-support (~> 3.13.0)
|
56
|
+
rspec-support (3.13.1)
|
57
|
+
rubocop (1.66.1)
|
46
58
|
json (~> 2.3)
|
59
|
+
language_server-protocol (>= 3.17.0)
|
47
60
|
parallel (~> 1.10)
|
48
|
-
parser (>= 3.
|
61
|
+
parser (>= 3.3.0.2)
|
49
62
|
rainbow (>= 2.2.2, < 4.0)
|
50
|
-
regexp_parser (>=
|
51
|
-
|
52
|
-
rubocop-ast (>= 1.23.0, < 2.0)
|
63
|
+
regexp_parser (>= 2.4, < 3.0)
|
64
|
+
rubocop-ast (>= 1.32.2, < 2.0)
|
53
65
|
ruby-progressbar (~> 1.7)
|
54
|
-
unicode-display_width (>=
|
55
|
-
rubocop-ast (1.
|
56
|
-
parser (>= 3.
|
57
|
-
rubocop-performance (1.
|
58
|
-
rubocop (>= 1.
|
59
|
-
rubocop-ast (>=
|
66
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
67
|
+
rubocop-ast (1.32.3)
|
68
|
+
parser (>= 3.3.1.0)
|
69
|
+
rubocop-performance (1.22.1)
|
70
|
+
rubocop (>= 1.48.1, < 2.0)
|
71
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
60
72
|
rubocop-rake (0.6.0)
|
61
73
|
rubocop (~> 1.0)
|
62
|
-
rubocop-rspec (
|
63
|
-
rubocop (~> 1.
|
64
|
-
ruby-progressbar (1.
|
74
|
+
rubocop-rspec (3.0.5)
|
75
|
+
rubocop (~> 1.61)
|
76
|
+
ruby-progressbar (1.13.0)
|
77
|
+
securerandom (0.3.1)
|
65
78
|
simplecov (0.22.0)
|
66
79
|
docile (~> 1.1)
|
67
80
|
simplecov-html (~> 0.11)
|
68
81
|
simplecov_json_formatter (~> 0.1)
|
69
|
-
simplecov-html (0.
|
82
|
+
simplecov-html (0.13.1)
|
70
83
|
simplecov_json_formatter (0.1.4)
|
71
|
-
tzinfo (2.0.
|
84
|
+
tzinfo (2.0.6)
|
72
85
|
concurrent-ruby (~> 1.0)
|
73
|
-
unicode-display_width (2.
|
74
|
-
|
75
|
-
yard (0.9.28)
|
76
|
-
webrick (~> 1.7.0)
|
77
|
-
zeitwerk (2.6.6)
|
86
|
+
unicode-display_width (2.6.0)
|
87
|
+
yard (0.9.37)
|
78
88
|
|
79
89
|
PLATFORMS
|
90
|
+
ruby
|
80
91
|
x86_64-linux
|
81
92
|
|
82
93
|
DEPENDENCIES
|
83
|
-
activesupport (~>
|
94
|
+
activesupport (~> 7.2)
|
84
95
|
bundler
|
85
96
|
byebug
|
86
97
|
rack
|
data/README.md
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
**This is a work in progress** but you're welcome to help, test, submit
|
7
7
|
issues, ...
|
8
8
|
|
9
|
-
**Note**
|
9
|
+
**Note**
|
10
|
+
- For Rails 5, use version 0.2.3
|
11
|
+
- For Rails 6/ruby 2.7, use version 0.7
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
@@ -79,6 +81,10 @@ require 'support/rspec_rails_api'
|
|
79
81
|
# Server URL for quick reference
|
80
82
|
server_url = 'https://example.com'
|
81
83
|
|
84
|
+
# Optional custom expected content type; default is "application/json; charset=utf-8".
|
85
|
+
# Note that rails adds the charset in the header.
|
86
|
+
# RSpec::Rails::Api::Metadata.default_expected_content_type = "application/json+custom; charset=utf-8"
|
87
|
+
|
82
88
|
# Options here should be present for a valid OpenAPI file
|
83
89
|
renderer.api_title = 'MyProject API'
|
84
90
|
renderer.api_version = '1'
|
@@ -546,7 +552,7 @@ on_post '/api/items' do
|
|
546
552
|
end
|
547
553
|
```
|
548
554
|
|
549
|
-
##### `for_code(http_status, description = nil, test_only: false &block)`
|
555
|
+
##### `for_code(http_status, description = nil, test_only: false, with_content_type: nil &block)`
|
550
556
|
|
551
557
|
Describes the desired output for a precedently defined URL.
|
552
558
|
|
@@ -66,7 +66,7 @@ module RSpec
|
|
66
66
|
# @param expected_code [Number] Code to test for
|
67
67
|
# @param ignore_content_type [Boolean] Whether to ignore the response's content-type for
|
68
68
|
# this response only
|
69
|
-
def check_response(response, expected_code, ignore_content_type: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
|
69
|
+
def check_response(response, expected_code, ignore_content_type: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
70
70
|
code_error_message = if response.status != expected_code && response.status == 422
|
71
71
|
<<~TXT
|
72
72
|
expected: #{expected_code}
|
@@ -77,7 +77,8 @@ module RSpec
|
|
77
77
|
|
78
78
|
expect(response.status).to eq(expected_code), code_error_message
|
79
79
|
if expected_code != 204 && !ignore_content_type
|
80
|
-
|
80
|
+
content_type = rra_current_example[:expectations][:content_type] || RSpec::Rails::Api::Metadata.default_expected_content_type # rubocop:disable Layout/LineLength
|
81
|
+
expect(response.headers['Content-Type'].downcase).to eq content_type
|
81
82
|
end
|
82
83
|
expectations = rra_current_example[:expectations]
|
83
84
|
expect(response).to have_many defined(expectations[:many]) if expectations[:many]
|
@@ -154,7 +155,7 @@ module RSpec
|
|
154
155
|
# Use everything else in query string
|
155
156
|
uri = URI.parse(url)
|
156
157
|
query_params = request_params.select { |k| used_path_params.exclude? k }
|
157
|
-
uri.query = URI.encode_www_form(query_params)
|
158
|
+
uri.query = URI.encode_www_form(query_params) if query_params.present?
|
158
159
|
|
159
160
|
uri.to_s
|
160
161
|
end
|
@@ -96,8 +96,8 @@ module RSpec
|
|
96
96
|
# @param [String] description Longer description
|
97
97
|
#
|
98
98
|
# @return [void]
|
99
|
-
def on_get(url, summary = nil, description = nil, &
|
100
|
-
on_action(:get, url, summary, description, &
|
99
|
+
def on_get(url, summary = nil, description = nil, &)
|
100
|
+
on_action(:get, url, summary, description, &)
|
101
101
|
end
|
102
102
|
|
103
103
|
##
|
@@ -108,8 +108,8 @@ module RSpec
|
|
108
108
|
# @param [String] description Longer description
|
109
109
|
#
|
110
110
|
# @return [void]
|
111
|
-
def on_post(url, summary = nil, description = nil, &
|
112
|
-
on_action(:post, url, summary, description, &
|
111
|
+
def on_post(url, summary = nil, description = nil, &)
|
112
|
+
on_action(:post, url, summary, description, &)
|
113
113
|
end
|
114
114
|
|
115
115
|
##
|
@@ -120,8 +120,8 @@ module RSpec
|
|
120
120
|
# @param [String] description Longer description
|
121
121
|
#
|
122
122
|
# @return [void]
|
123
|
-
def on_put(url, summary = nil, description = nil, &
|
124
|
-
on_action(:put, url, summary, description, &
|
123
|
+
def on_put(url, summary = nil, description = nil, &)
|
124
|
+
on_action(:put, url, summary, description, &)
|
125
125
|
end
|
126
126
|
|
127
127
|
##
|
@@ -132,8 +132,8 @@ module RSpec
|
|
132
132
|
# @param [String] description Longer description
|
133
133
|
#
|
134
134
|
# @return [void]
|
135
|
-
def on_patch(url, summary = nil, description = nil, &
|
136
|
-
on_action(:patch, url, summary, description, &
|
135
|
+
def on_patch(url, summary = nil, description = nil, &)
|
136
|
+
on_action(:patch, url, summary, description, &)
|
137
137
|
end
|
138
138
|
|
139
139
|
##
|
@@ -144,27 +144,28 @@ module RSpec
|
|
144
144
|
# @param [String] description Longer description
|
145
145
|
#
|
146
146
|
# @return [void]
|
147
|
-
def on_delete(url, summary = nil, description = nil, &
|
148
|
-
on_action(:delete, url, summary, description, &
|
147
|
+
def on_delete(url, summary = nil, description = nil, &)
|
148
|
+
on_action(:delete, url, summary, description, &)
|
149
149
|
end
|
150
150
|
|
151
151
|
##
|
152
152
|
# Adds an HTTP code declaration to metadata, with expected result
|
153
153
|
# If no expectation is provided, the response will be expected to be empty
|
154
154
|
#
|
155
|
-
# @param status_code
|
156
|
-
# @param description
|
157
|
-
# @param expect_many
|
158
|
-
# @param expect_one
|
159
|
-
# @param
|
155
|
+
# @param status_code [Number] Status code to test for
|
156
|
+
# @param description [String] Description of the route/status pair
|
157
|
+
# @param expect_many [Symbol] Check the response for a list of given entity
|
158
|
+
# @param expect_one [Symbol] Check the response for a given entity
|
159
|
+
# @param with_content_type [String, nil] Check for a custom content type instead of using de default one
|
160
|
+
# @param test_only [Boolean] When true, test the response without filling the documentation
|
160
161
|
#
|
161
162
|
# @return [void]
|
162
163
|
#
|
163
|
-
def for_code(status_code, description = nil, expect_many: nil, expect_one: false, test_only: false, &block)
|
164
|
+
def for_code(status_code, description = nil, expect_many: nil, expect_one: false, test_only: false, with_content_type: nil, &block) # rubocop:disable Layout/LineLength, Metrics/ParameterLists
|
164
165
|
description ||= Rack::Utils::HTTP_STATUS_CODES[status_code]
|
165
166
|
|
166
167
|
metadata[:rra].add_status_code(status_code, description) unless test_only
|
167
|
-
metadata[:rra].add_expectations(expect_one, expect_many)
|
168
|
+
metadata[:rra].add_expectations(expect_one, expect_many, content_type: with_content_type)
|
168
169
|
metadata[:rra_current_example] = metadata[:rra].current_example
|
169
170
|
|
170
171
|
describe "->#{test_only ? ' test' : ''} #{status_code} - #{description}" do
|
@@ -183,10 +184,10 @@ module RSpec
|
|
183
184
|
# @param [String, nil] description Longer description
|
184
185
|
#
|
185
186
|
# @return [void]
|
186
|
-
def on_action(action, url, summary, description, &
|
187
|
+
def on_action(action, url, summary, description, &)
|
187
188
|
metadata[:rra].add_action(action, url, summary, description)
|
188
189
|
|
189
|
-
describe("#{action.upcase} #{url}", &
|
190
|
+
describe("#{action.upcase} #{url}", &)
|
190
191
|
end
|
191
192
|
|
192
193
|
##
|
@@ -47,6 +47,14 @@ module RSpec
|
|
47
47
|
def reset
|
48
48
|
@entities = {}
|
49
49
|
end
|
50
|
+
|
51
|
+
def default_expected_content_type
|
52
|
+
@default_expected_content_type ||= 'application/json; charset=utf-8'
|
53
|
+
end
|
54
|
+
|
55
|
+
def default_expected_content_type=(value)
|
56
|
+
@default_expected_content_type = value.downcase
|
57
|
+
end
|
50
58
|
end
|
51
59
|
|
52
60
|
##
|
@@ -202,9 +210,10 @@ module RSpec
|
|
202
210
|
#
|
203
211
|
# @param one [Hash, nil] Entity definition
|
204
212
|
# @param many [Hash, nil] Entity definition
|
213
|
+
# @param content_type [String, nil] Custom content type
|
205
214
|
#
|
206
215
|
# @return [void]
|
207
|
-
def add_expectations(one, many)
|
216
|
+
def add_expectations(one, many, content_type: nil)
|
208
217
|
check_current_context :resource, :url, :method, :code
|
209
218
|
none = !many && !one
|
210
219
|
|
@@ -212,9 +221,10 @@ module RSpec
|
|
212
221
|
Utils.deep_set(@resources,
|
213
222
|
[@current_resource, 'paths', @current_url, 'actions', @current_method, 'statuses', @current_code, 'expectations'],
|
214
223
|
{
|
215
|
-
one:
|
216
|
-
many:
|
217
|
-
none:
|
224
|
+
one: one,
|
225
|
+
many: many,
|
226
|
+
none: none,
|
227
|
+
content_type: content_type,
|
218
228
|
})
|
219
229
|
# rubocop:enable Layout/LineLength
|
220
230
|
end
|
@@ -38,12 +38,10 @@ module RSpec
|
|
38
38
|
# Adds a security scheme definition to the API documentation
|
39
39
|
#
|
40
40
|
# @param reference [Symbol] Reference to use in the tests
|
41
|
-
# @param name [String] Human friendly name
|
42
41
|
# @param definition [Hash] Security scheme definition as per https://swagger.io/specification/#security-scheme-object
|
43
|
-
def add_security_scheme(reference,
|
42
|
+
def add_security_scheme(reference, definition)
|
44
43
|
raise "Security scheme #{reference} is already defined" if @api_security.key? reference
|
45
44
|
|
46
|
-
definition[:name] = name unless reference == :basic
|
47
45
|
@api_security[reference] = definition
|
48
46
|
end
|
49
47
|
|
@@ -215,12 +213,9 @@ module RSpec
|
|
215
213
|
#
|
216
214
|
# @param params [Hash] Path parameters
|
217
215
|
def process_path_params(params)
|
218
|
-
|
219
|
-
|
220
|
-
parameters.push process_path_param name, param
|
216
|
+
params.map do |name, param|
|
217
|
+
process_path_param name, param
|
221
218
|
end
|
222
|
-
|
223
|
-
parameters
|
224
219
|
end
|
225
220
|
|
226
221
|
def process_entity(entity) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -250,7 +245,7 @@ module RSpec
|
|
250
245
|
schema[:properties][name] = property
|
251
246
|
end
|
252
247
|
|
253
|
-
schema[:required] = required unless required.
|
248
|
+
schema[:required] = required unless required.empty?
|
254
249
|
|
255
250
|
schema
|
256
251
|
end
|
@@ -59,7 +59,7 @@ module RSpec
|
|
59
59
|
# @param values [String] JSON string representing the value
|
60
60
|
#
|
61
61
|
# @return [String]
|
62
|
-
def format_failure_message(errors, values)
|
62
|
+
def format_failure_message(errors, values) # rubocop:disable Metrics/MethodLength
|
63
63
|
if errors.is_a? Hash
|
64
64
|
errors = errors.deep_stringify_keys.to_yaml.split("\n")
|
65
65
|
errors.shift
|
data/rspec-rails-api.gemspec
CHANGED
@@ -33,18 +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 = '>=
|
37
|
-
|
38
|
-
spec.add_development_dependency 'activesupport', '~> 6.0'
|
39
|
-
spec.add_development_dependency 'bundler'
|
40
|
-
spec.add_development_dependency 'byebug'
|
41
|
-
spec.add_development_dependency 'rack'
|
42
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
43
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
44
|
-
spec.add_development_dependency 'rubocop'
|
45
|
-
spec.add_development_dependency 'rubocop-performance'
|
46
|
-
spec.add_development_dependency 'rubocop-rake'
|
47
|
-
spec.add_development_dependency 'rubocop-rspec'
|
48
|
-
spec.add_development_dependency 'simplecov'
|
49
|
-
spec.add_development_dependency 'yard'
|
36
|
+
spec.required_ruby_version = '>= 3.1.2'
|
50
37
|
end
|
metadata
CHANGED
@@ -1,183 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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: 2024-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '6.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '6.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: byebug
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rack
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '10.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '10.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop-performance
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-rake
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rubocop-rspec
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: simplecov
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: yard
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
11
|
+
date: 2024-09-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
181
13
|
description: |
|
182
14
|
Create acceptance tests to check the Rails API responses and generate
|
183
15
|
documentation from it.
|
@@ -230,14 +62,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
62
|
requirements:
|
231
63
|
- - ">="
|
232
64
|
- !ruby/object:Gem::Version
|
233
|
-
version:
|
65
|
+
version: 3.1.2
|
234
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
67
|
requirements:
|
236
68
|
- - ">="
|
237
69
|
- !ruby/object:Gem::Version
|
238
70
|
version: '0'
|
239
71
|
requirements: []
|
240
|
-
rubygems_version: 3.4.
|
72
|
+
rubygems_version: 3.4.15
|
241
73
|
signing_key:
|
242
74
|
specification_version: 4
|
243
75
|
summary: Tests standard Rails API responses and generate doc
|