rspec-rails-api 0.9.1 → 0.9.2
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/rspec/rails/api/dsl/example.rb +33 -4
- data/lib/rspec/rails/api/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36fe79a8d00eac7bac5fcf841239e39a73ff8a7c47db046bbe18590e0db4085a
|
|
4
|
+
data.tar.gz: 59e955a181a272b105015901e94268fab2cd67c0119f7cbcef8cc153a8e47450
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e164de7f7023e524ce047c87883d569e82559c0fbfc7311bbdfff4b0fbefa68aceaf653ffc3d7232c750092cdd17d75c1a57837c10c3c34fecf8d650f2507578
|
|
7
|
+
data.tar.gz: 21cef61f13ceeb836165e4779ae0b191577ab31d78ad8677fc53afdbdb10a5880f7a8b6dc557b25d4b9bf3b6e95c8eadae3c9090a58d8cb3f05edda2ee5a7951
|
data/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,14 @@ Maintenance, in case of rework, dependencies change
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [0.9.2] - 2026-06-14
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Improved support for `file`s upload : when a payload contains a `Rack::Test::UploadedFile`, it will not be transformed to JSON
|
|
26
|
+
and the example, while not representing a `multipart/form-data` payload, will display something like
|
|
27
|
+
`'<file content: file_name.txt>'` instead of the UploadedFile representation.
|
|
28
|
+
|
|
21
29
|
## [0.9.1] - 2025-12-12
|
|
22
30
|
|
|
23
31
|
### Fixed
|
data/Gemfile.lock
CHANGED
|
@@ -5,7 +5,7 @@ module RSpec
|
|
|
5
5
|
module Api
|
|
6
6
|
module DSL
|
|
7
7
|
# These methods will be available in examples (i.e.: 'for_code')
|
|
8
|
-
module Example
|
|
8
|
+
module Example # rubocop:disable Metrics/ModuleLength
|
|
9
9
|
##
|
|
10
10
|
# Visits the current example and tests the response
|
|
11
11
|
#
|
|
@@ -101,7 +101,19 @@ module RSpec
|
|
|
101
101
|
status_code: status_code,
|
|
102
102
|
response: response,
|
|
103
103
|
path_params: request_params[:path_params],
|
|
104
|
-
params: request_params[:params])
|
|
104
|
+
params: strip_files(request_params[:params]))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Replaces Rack::Test::UploadedFile content by a string
|
|
108
|
+
#
|
|
109
|
+
# @param data - Data to use in an API call
|
|
110
|
+
# @return Same object with UploadedFile replaced by a string
|
|
111
|
+
def strip_files(data)
|
|
112
|
+
return data.map { |d| strip_files(d) } if data.is_a?(Array)
|
|
113
|
+
return data.transform_values { |v| strip_files(v) } if data.is_a?(Hash)
|
|
114
|
+
return "<file content: #{data.original_filename}>" if data.is_a?(Rack::Test::UploadedFile)
|
|
115
|
+
|
|
116
|
+
data
|
|
105
117
|
end
|
|
106
118
|
|
|
107
119
|
##
|
|
@@ -113,11 +125,13 @@ module RSpec
|
|
|
113
125
|
# @param request_headers [Hash] Custom headers
|
|
114
126
|
#
|
|
115
127
|
# @return [Hash] Options for the request
|
|
116
|
-
def prepare_request_params(description, request_params = {}, payload = {}, request_headers = {})
|
|
128
|
+
def prepare_request_params(description, request_params = {}, payload = {}, request_headers = {}) # rubocop:disable Metrics/MethodLength
|
|
117
129
|
example_params = description.split
|
|
118
130
|
verb = example_params[0].downcase
|
|
119
131
|
|
|
120
|
-
|
|
132
|
+
has_form_data = contains_file?(payload)
|
|
133
|
+
payload = payload.to_json if verb != 'get' && !has_form_data
|
|
134
|
+
request_headers['Content-Type'] = 'multipart/form-data' if has_form_data
|
|
121
135
|
|
|
122
136
|
{
|
|
123
137
|
action: verb,
|
|
@@ -202,6 +216,21 @@ module RSpec
|
|
|
202
216
|
def rra_metadata
|
|
203
217
|
self.class.metadata[:rra]
|
|
204
218
|
end
|
|
219
|
+
|
|
220
|
+
# Checks if provided data contains a Rack::Test::UploadedFile
|
|
221
|
+
#
|
|
222
|
+
# @param data - Data used in an API call
|
|
223
|
+
# @return [Boolean]
|
|
224
|
+
def contains_file?(data) # rubocop:disable Metrics/CyclomaticComplexity
|
|
225
|
+
return false unless data.is_a?(Hash) || data.is_a?(Array)
|
|
226
|
+
|
|
227
|
+
iterator = data.is_a?(Hash) ? data.values : data
|
|
228
|
+
iterator.each do |v|
|
|
229
|
+
return true if v.is_a?(Rack::Test::UploadedFile) || (v.is_a?(Hash) && contains_file?(v))
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
false
|
|
233
|
+
end
|
|
205
234
|
end
|
|
206
235
|
end
|
|
207
236
|
end
|
metadata
CHANGED
|
@@ -1,13 +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.
|
|
4
|
+
version: 0.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Manuel Tancoigne
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-06-14 00:00:00.000000000 Z
|
|
11
12
|
dependencies: []
|
|
12
13
|
description: |
|
|
13
14
|
Create acceptance tests to check the Rails API responses and generate
|
|
@@ -53,6 +54,7 @@ metadata:
|
|
|
53
54
|
bug_tracker_uri: https://gitlab.com/experimentslabs/rspec-rails-api/issues
|
|
54
55
|
changelog_uri: https://gitlab.com/experimentslabs/rspec-rails-api/blob/master/CHANGELOG.md
|
|
55
56
|
rubygems_mfa_required: 'true'
|
|
57
|
+
post_install_message:
|
|
56
58
|
rdoc_options: []
|
|
57
59
|
require_paths:
|
|
58
60
|
- lib
|
|
@@ -67,7 +69,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
67
69
|
- !ruby/object:Gem::Version
|
|
68
70
|
version: '0'
|
|
69
71
|
requirements: []
|
|
70
|
-
rubygems_version: 3.
|
|
72
|
+
rubygems_version: 3.5.22
|
|
73
|
+
signing_key:
|
|
71
74
|
specification_version: 4
|
|
72
75
|
summary: Tests standard Rails API responses and generate doc
|
|
73
76
|
test_files: []
|