spec/grape/validations_spec.rb in grape-1.7.0 vs spec/grape/validations_spec.rb in grape-1.7.1
- old
+ new
@@ -1069,16 +1069,16 @@
{ top_id: nil, missing_top_id: 4 }
]
}
# debugger
get '/multi_level', data
- expect(last_response.body.split(', ')).to match_array([
- 'top[3][top_id] is empty',
- 'top[2][middle_1][0][middle_1_id] is empty',
- 'top[1][middle_1][1][middle_2][0][middle_2_id] is empty',
- 'top[0][middle_1][1][middle_2][1][bottom][0][bottom_id] is empty'
- ])
+ expect(last_response.body.split(', ')).to contain_exactly(
+ 'top[3][top_id] is empty',
+ 'top[2][middle_1][0][middle_1_id] is empty',
+ 'top[1][middle_1][1][middle_2][0][middle_2_id] is empty',
+ 'top[0][middle_1][1][middle_2][1][bottom][0][bottom_id] is empty'
+ )
expect(last_response.status).to eq(400)
end
end
end
@@ -1504,9 +1504,32 @@
it 'works' do
get '/shared_params'
expect(last_response.status).to eq(200)
expect(last_response.body).to eq({ param: 'value' }.to_json)
+ end
+ end
+
+ context 'with block and empty args' do
+ before do
+ subject.helpers do
+ params :shared_params do |empty_args|
+ optional :param, default: empty_args[:some]
+ end
+ end
+ subject.format :json
+ subject.params do
+ use :shared_params
+ end
+ subject.get '/shared_params' do
+ :ok
+ end
+ end
+
+ it 'works' do
+ get '/shared_params'
+
+ expect(last_response.status).to eq(200)
end
end
context 'all or none' do
context 'optional params' do