File: validation_spec.rb

package info (click to toggle)
ruby-grape 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,488 kB
  • sloc: ruby: 21,014; makefile: 6
file content (17 lines) | stat: -rw-r--r-- 645 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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