Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lib/grape/exceptions/validation_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ValidationErrors < Grape::Exceptions::Base
attr_reader :errors

def initialize(args = {})
fail 'Params are missing:' unless args.key? :errors
@errors = {}
args[:errors].each do |validation_error|
@errors[validation_error.params] ||= []
Expand Down
4 changes: 4 additions & 0 deletions spec/grape/exceptions/validation_errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
it 'should assign headers through base class' do
expect(subject.headers).to eq(headers)
end

it 'fails when params are missing' do
expect { described_class.new(headers: headers) }.to raise_error(RuntimeError, 'Params are missing:')
end
end

context 'message' do
Expand Down