rswag-specs 2.9.0 → 2.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: fa8f8005ed229944c19cb2e33e09eaebb95b8e32b9bef505a5e6b64b237bcbdc
4
- data.tar.gz: 7eebf43807f0252c3168e08283b716c3dd9356f5d79fde1fcfc275377b5bc522
3
+ metadata.gz: 6d30046aab2de448f6194ded5849b09684c36be6e1b5e703858647bca6bb3301
4
+ data.tar.gz: 24bd271875ee9011313a2866930c7b045175638564d35e5816e5b3ad75fb59d7
5
5
  SHA512:
6
- metadata.gz: e99187485ac197dad84d0f28b9bdec67c0e11b10efb5f2561a939e48852a6fc28505d2c92feb49a2969dd6a5a7919279986a05d9c3d09db2dc15581b085908ed
7
- data.tar.gz: 1da746e08c42864094b13f36b72587f1d05b55922106ac1888accf16ac1bfae84c5fafb28dfa5952c47b477742b592bfff915743842523104f28e416859c1889
6
+ metadata.gz: b61f3ac5b3d790eadc1d424ec2bebc967fbd97cafb22de3a4d7186c421d83bd4283b6bf0c63c450f749f969b8a5244490a74e5355179b62f615847e26759a53a
7
+ data.tar.gz: 03af0fb0ed593daa9e6e9d9102aa74445bffbe65fa20a473b157c90b7a82120660d23cee13b84c9986d3ecc601525a3c5c6e68969a4b37e109433a5e1d1be651
@@ -0,0 +1,17 @@
1
+ RSpec:
2
+ Language:
3
+ ExampleGroups:
4
+ Regular:
5
+ - path
6
+ - response
7
+ - get
8
+ - post
9
+ - patch
10
+ - put
11
+ - delete
12
+ - head
13
+ - options
14
+ - trace
15
+ Examples:
16
+ Regular:
17
+ - run_test!
@@ -13,9 +13,9 @@ module Rswag
13
13
  end
14
14
 
15
15
  [:get, :post, :patch, :put, :delete, :head, :options, :trace].each do |verb|
16
- define_method(verb) do |summary, &block|
17
- api_metadata = { operation: { verb: verb, summary: summary } }
18
- describe(verb, api_metadata, &block)
16
+ define_method(verb) do |summary, **metadata, &block|
17
+ api_metadata = { operation: { verb: verb, summary: summary } }.deep_merge(metadata)
18
+ describe(verb, **api_metadata, &block)
19
19
  end
20
20
  end
21
21
 
@@ -55,7 +55,6 @@ module Rswag
55
55
  end
56
56
  end
57
57
 
58
-
59
58
  def request_body_example(value:, summary: nil, name: nil)
60
59
  if metadata.key?(:operation)
61
60
  metadata[:operation][:request_examples] ||= []
@@ -118,19 +117,24 @@ module Rswag
118
117
  #
119
118
  # Perform request and assert response matches swagger definitions
120
119
  #
120
+ # @param description [String] description of the test
121
+ # @param args [Array] arguments to pass to the `it` method
121
122
  # @param options [Hash] options to pass to the `it` method
122
123
  # @param &block [Proc] you can make additional assertions within that block
123
124
  # @return [void]
124
- def run_test!(**options, &block)
125
+ def run_test!(description = nil, *args, **options, &block)
126
+ # rswag metadata value defaults to true
125
127
  options[:rswag] = true unless options.key?(:rswag)
126
128
 
129
+ description ||= "returns a #{metadata[:response][:code]} response"
130
+
127
131
  if RSPEC_VERSION < 3
128
132
  ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: Support for RSpec 2.X will be dropped in v3.0')
129
133
  before do
130
134
  submit_request(example.metadata)
131
135
  end
132
136
 
133
- it "returns a #{metadata[:response][:code]} response", **options do
137
+ it description, *args, **options do
134
138
  assert_response_matches_metadata(metadata)
135
139
  block.call(response) if block_given?
136
140
  end
@@ -139,7 +143,7 @@ module Rswag
139
143
  submit_request(example.metadata)
140
144
  end
141
145
 
142
- it "returns a #{metadata[:response][:code]} response", **options do |example|
146
+ it description, *args, **options do |example|
143
147
  assert_response_matches_metadata(example.metadata, &block)
144
148
  example.instance_exec(response, &block) if block_given?
145
149
  end
@@ -142,6 +142,7 @@ module Rswag
142
142
 
143
143
  def build_query_string_part(param, value, swagger_doc)
144
144
  name = param[:name]
145
+ escaped_name = CGI.escape(name.to_s)
145
146
 
146
147
  # OAS 3: https://swagger.io/docs/specification/serialization/
147
148
  if swagger_doc && doc_version(swagger_doc).start_with?('3') && param[:schema]
@@ -157,20 +158,20 @@ module Rswag
157
158
  if explode
158
159
  return value.to_query
159
160
  else
160
- return "#{CGI.escape(name.to_s)}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(',')
161
+ return "#{escaped_name}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(',')
161
162
  end
162
163
  end
163
164
  when :array
164
165
  case explode
165
166
  when true
166
- return value.to_a.flatten.map{|v| "#{CGI.escape(name.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
167
+ return value.to_a.flatten.map{|v| "#{escaped_name}=#{CGI.escape(v.to_s)}"}.join('&')
167
168
  else
168
169
  separator = case style
169
170
  when :form then ','
170
171
  when :spaceDelimited then '%20'
171
172
  when :pipeDelimited then '|'
172
173
  end
173
- return "#{CGI.escape(name.to_s)}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(separator)
174
+ return "#{escaped_name}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(separator)
174
175
  end
175
176
  else
176
177
  return "#{name}=#{value}"
@@ -178,7 +179,7 @@ module Rswag
178
179
  end
179
180
 
180
181
  type = param[:type] || param.dig(:schema, :type)
181
- return "#{name}=#{value}" unless type&.to_sym == :array
182
+ return "#{escaped_name}=#{CGI.escape(value.to_s)}" unless type&.to_sym == :array
182
183
 
183
184
  case param[:collectionFormat]
184
185
  when :ssv
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rswag-specs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richie Morris
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-04-24 00:00:00.000000000 Z
13
+ date: 2023-07-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -109,6 +109,7 @@ executables: []
109
109
  extensions: []
110
110
  extra_rdoc_files: []
111
111
  files:
112
+ - ".rubocop_rspec_alias_config.yml"
112
113
  - MIT-LICENSE
113
114
  - Rakefile
114
115
  - lib/generators/rspec/USAGE