-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Spec describing the issue
it 'declared Hash groups should be a Hash' do
app.params do
optional :group, type: Hash do
optional :foo, type: String
end
end
app.get :group do
declared(params).to_json
end
get '/group'
json = JSON.parse(last_response.body)
puts json['group'].class.name
expect(json['group']).to be_kind_of(Hash)
end
This produces the following output
Array
Failure/Error: expect(json['group']).to be_kind_of(Hash)
expected [] to be a kind of Hash
Setting a default on the param is a workaround
it 'declared Hash groups should be a Hash' do
app.params do
optional :group, type: Hash, default: {} do
optional :foo, type: String
end
end
app.get :group do
declared(params).to_json
end
get '/group'
json = JSON.parse(last_response.body)
puts json['group']
expect(json['group']).to be_kind_of(Hash)
end
This spec passes without error with the expected output
{ "foo" => nil }
Using Grape v0.14.0, running specs on master
dandlezzz, travisp and TheAbyss