Sha256: fc3bf4e853d5d411e152d044f7e0fc37e3a2f9ea6bc97092925754a937a166d0

Contents?: true

Size: 614 Bytes

Versions: 3

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

describe Grape::Exceptions::Validation do
  it 'fails when params are missing' do
    expect { described_class.new(message: 'presence') }.to raise_error(ArgumentError, /missing keyword:.+?params/)
  end

  context 'when message is a symbol' do
    it 'stores message_key' do
      expect(described_class.new(params: ['id'], message: :presence).message_key).to eq(:presence)
    end
  end

  context 'when message is a String' do
    it 'does not store the message_key' do
      expect(described_class.new(params: ['id'], message: 'presence').message_key).to be_nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grape-1.8.0 spec/grape/exceptions/validation_spec.rb
grape-1.7.1 spec/grape/exceptions/validation_spec.rb
grape-1.7.0 spec/grape/exceptions/validation_spec.rb