Skip to content

Add a fail spec for #705 #707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions spec/swagger_v2/api_swagger_v2_is_array_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'desc is_array option' do
let(:app) do
class User < Grape::Entity
expose :name
end
Class.new(Grape::API) do
namespace :hash do
desc 'Get users',
success: User,
is_array: true
get {}
end
namespace :block do
desc 'Get users' do
success User
is_array true
end
get {}
end

add_swagger_documentation format: :json
end
end

subject do
get '/swagger_doc'
JSON.parse(last_response.body)
end

def type_in_success_response_schema(style)
subject['paths']["/#{style}"]['get']['responses']['200']['schema']['type']
end

context 'in hash style' do
it { expect(type_in_success_response_schema('hash')).to eq 'array' }
end

context 'in block style' do
it { expect(type_in_success_response_schema('block')).to eq 'array' }
end
end