Sha256: b5f2d172b2d070d50663284150091ee40c292e7257f0ee18fd4cc01a46b568d7

Contents?: true

Size: 645 Bytes

Versions: 17

Compression:

Stored size: 645 Bytes

Contents

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

17 entries across 17 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/spec/grape/exceptions/validation_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/spec/grape/exceptions/validation_spec.rb
grape-1.2.5 spec/grape/exceptions/validation_spec.rb
grape-1.2.4 spec/grape/exceptions/validation_spec.rb
grape-1.2.3 spec/grape/exceptions/validation_spec.rb
grape-1.2.2 spec/grape/exceptions/validation_spec.rb
grape-1.2.1 spec/grape/exceptions/validation_spec.rb
grape-1.2.0 spec/grape/exceptions/validation_spec.rb
grape-1.1.0 spec/grape/exceptions/validation_spec.rb
grape-1.0.3 spec/grape/exceptions/validation_spec.rb
grape-1.0.2 spec/grape/exceptions/validation_spec.rb
grape-1.0.1 spec/grape/exceptions/validation_spec.rb
grape-1.0.0 spec/grape/exceptions/validation_spec.rb
grape-0.19.2 spec/grape/exceptions/validation_spec.rb
grape-0.19.1 spec/grape/exceptions/validation_spec.rb
grape-0.19.0 spec/grape/exceptions/validation_spec.rb
grape-0.18.0 spec/grape/exceptions/validation_spec.rb