Sha256: 77b3d69417ca6dd84da4d18eb277ba3cba052fc754d8f6f6035f01f4b68dc2de

Contents?: true

Size: 678 Bytes

Versions: 11

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Grape::Exceptions::Validation do
  it 'fails when params are missing' do
    expect { Grape::Exceptions::Validation.new(message: 'presence') }.to raise_error(ArgumentError, /missing keyword:.+?params/)
  end
  context 'when message is a symbol' do
    it 'stores message_key' do
      expect(Grape::Exceptions::Validation.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(Grape::Exceptions::Validation.new(params: ['id'], message: 'presence').message_key).to eq(nil)
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
grape-1.6.0 spec/grape/exceptions/validation_spec.rb
grape-1.5.3 spec/grape/exceptions/validation_spec.rb
grape-1.5.2 spec/grape/exceptions/validation_spec.rb
grape-1.5.1 spec/grape/exceptions/validation_spec.rb
grape-1.5.0 spec/grape/exceptions/validation_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/spec/grape/exceptions/validation_spec.rb
grape-1.4.0 spec/grape/exceptions/validation_spec.rb
grape-1.3.3 spec/grape/exceptions/validation_spec.rb
grape-1.3.2 spec/grape/exceptions/validation_spec.rb
grape-1.3.1 spec/grape/exceptions/validation_spec.rb
grape-1.3.0 spec/grape/exceptions/validation_spec.rb