spec/grape/validations/validators/presence_spec.rb in grape-0.18.0 vs spec/grape/validations/validators/presence_spec.rb in grape-0.19.0

- old
+ new

@@ -103,10 +103,38 @@ expect(last_response.status).to eq(200) expect(last_response.body).to eq('Hello'.to_json) end end + context 'with multiple parameters per requires' do + before do + subject.params do + requires :one, :two + end + subject.get '/single-requires' do + 'Hello' + end + + subject.params do + requires :one + requires :two + end + subject.get '/multiple-requires' do + 'Hello' + end + end + it 'validates for all defined params' do + get '/single-requires' + expect(last_response.status).to eq(400) + single_requires_error = last_response.body + + get '/multiple-requires' + expect(last_response.status).to eq(400) + expect(last_response.body).to eq(single_requires_error) + end + end + context 'with required parameters and no type' do before do subject.params do requires :name, :company end @@ -115,10 +143,10 @@ end end it 'validates name, company' do get '/' expect(last_response.status).to eq(400) - expect(last_response.body).to eq('{"error":"name is missing"}') + expect(last_response.body).to eq('{"error":"name is missing, company is missing"}') get '/', name: 'Bob' expect(last_response.status).to eq(400) expect(last_response.body).to eq('{"error":"company is missing"}')