mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 15:22:56 +00:00
adds request spec generator shamelessly stollen from rspec-rails-swagger
This commit is contained in:
30
rswag-specs/lib/generators/rspec/swagger/templates/spec.rb
Normal file
30
rswag-specs/lib/generators/rspec/swagger/templates/spec.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
require 'swagger_helper'
|
||||
|
||||
RSpec.describe '<%= controller_path %>', type: :request do
|
||||
<% @routes.each do | template, path_item | %>
|
||||
path '<%= template %>' do
|
||||
<% unless path_item[:params].empty? -%>
|
||||
# You'll want to customize the parameter types...
|
||||
<% path_item[:params].each do |param| -%>
|
||||
parameter '<%= param %>', in: :body, type: :string
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% path_item[:actions].each do | action, details | -%>
|
||||
<%= action %>('<%= details[:summary] %>') do
|
||||
response(200, 'successful') do
|
||||
<% unless path_item[:params].empty? -%>
|
||||
<% path_item[:params].each do |param| -%>
|
||||
let(:<%= param %>) { '123' }
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
||||
after do |example|
|
||||
example.metadata[:response][:examples] = { 'application/json' => JSON.parse(response.body, symbolize_names: true) }
|
||||
end
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
<% end -%>
|
||||
end
|
||||
<% end -%>
|
||||
end
|
||||
Reference in New Issue
Block a user