Gets v3 request example saving as well as response example saving

Adds rubocop to the gemset

adds guard to the gemset for testing
This commit is contained in:
Jay Danielian
2019-07-05 15:59:47 -04:00
parent 5d7fc44af4
commit 297cc447c8
24 changed files with 458 additions and 261 deletions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'swagger_helper'
describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
@@ -10,9 +12,12 @@ describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
operationId 'createBlog'
consumes 'application/json'
produces 'application/json'
parameter name: :blog, in: :body, schema: { '$ref' => '#/components/schemas/blog' }
# parameter name: :blog, in: :body, schema: { '$ref' => '#/components/schemas/blog' }
let(:blog) { { title: 'foo', content: 'bar' } }
request_body_json schema: { '$ref' => '#/components/schemas/blog' },
examples: :blog
let(:blog) { { blog: { title: 'foo', content: 'bar' } } }
response '201', 'blog created' do
run_test!
@@ -21,7 +26,7 @@ describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
response '422', 'invalid request' do
schema '$ref' => '#/components/schemas/errors_object'
let(:blog) { { title: 'foo' } }
let(:blog) { { blog: { title: 'foo' } } }
run_test! do |response|
expect(response.body).to include("can't be blank")
end
@@ -42,7 +47,7 @@ describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
end
response '406', 'unsupported accept header' do
let(:'Accept') { 'application/foo' }
let(:Accept) { 'application/foo' }
run_test!
end
end
@@ -68,11 +73,11 @@ describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
schema '$ref' => '#/components/schemas/blog'
examples 'application/json' => {
id: 1,
title: 'Hello world!',
content: 'Hello world and hello universe. Thank you all very much!!!',
thumbnail: "thumbnail.png"
}
id: 1,
title: 'Hello world!',
content: 'Hello world and hello universe. Thank you all very much!!!',
thumbnail: 'thumbnail.png'
}
let(:id) { blog.id }
run_test!
@@ -96,10 +101,10 @@ describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
description 'Upload a thumbnail for specific blog by id'
operationId 'uploadThumbnailBlog'
consumes 'multipart/form-data'
parameter name: :file, :in => :formData, :type => :file, required: true
parameter name: :file, in: :formData, type: :file, required: true
response '200', 'blog updated' do
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join("spec/fixtures/thumbnail.png")) }
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/thumbnail.png')) }
run_test!
end
end