Skip to content
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

DSL::Desc hash options are overriden by initializing them in block #706

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion spec/swagger_v2/nicknamed_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
require 'spec_helper'

describe 'a nicknamed mounted api' do
class Test < Grape::Entity
expose :at do
Time.now
end
end

def app
Class.new(Grape::API) do
desc 'Show this endpoint', nickname: 'simple'
desc 'Show this endpoint', nickname: 'simple' do
success Test
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

success overrides nickname so nickname is set to default value now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv Hash options combined with block options is deprecated. We shouldn't do that. Instead, use

desc 'Show this endpoint', nickname: 'simple', success: Test

or

desc 'Show this endpoint' do
  nickname 'simple'
  success Test
end

The test will pass.

end
get '/simple' do
{ foo: 'bar' }
end
Expand Down