-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathhash_spec.rb
38 lines (33 loc) · 1.27 KB
/
hash_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
describe Grape::Extensions::Hash::ParamBuilder do
describe 'deprecation' do
context 'when included' do
subject do
Class.new(Grape::API) do
include Grape::Extensions::Hash::ParamBuilder
end
end
let(:message) do
'This concern has been deprecated. Use `build_with` with one of the following short_name (:hash, :hash_with_indifferent_access, :hashie_mash) instead.'
end
it 'raises a deprecation' do
expect(Grape.deprecator).to receive(:warn).with(message).and_raise(ActiveSupport::DeprecationException, :deprecated)
expect { subject }.to raise_error(ActiveSupport::DeprecationException, 'deprecated')
end
end
context 'when using class name' do
let(:app) do
Class.new(Grape::API) do
params do
build_with Grape::Extensions::Hash::ParamBuilder
end
get
end
end
it 'raises a deprecation' do
expect(Grape.deprecator).to receive(:warn).with("#{described_class} has been deprecated. Use short name :hash instead.").and_raise(ActiveSupport::DeprecationException, :deprecated)
expect { get '/' }.to raise_error(ActiveSupport::DeprecationException, 'deprecated')
end
end
end
end