Skip to content

Commit cd0844f

Browse files
committed
Add specs for Parameters#use
1 parent 5b9cd71 commit cd0844f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

spec/grape/dsl/parameters_spec.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module DSL
55
module ParametersSpec
66
class Dummy
77
include Grape::DSL::Parameters
8+
attr_accessor :api
89

910
def validate_attributes(*args)
1011
@validate_attributes = *args
@@ -41,8 +42,21 @@ def validates_reader
4142
describe Parameters do
4243
subject { ParametersSpec::Dummy.new }
4344

44-
xdescribe '#use' do
45-
it 'does some thing'
45+
describe '#use' do
46+
before { allow(subject.api).to receive(:namespace_stackable).with(:named_params) }
47+
let(:options) { { option: 'value' } }
48+
let(:named_params) { { params_group: proc {} } }
49+
50+
it 'calls processes associated with named params' do
51+
allow(Grape::DSL::Configuration).to receive(:stacked_hash_to_hash).and_return(named_params)
52+
expect(subject).to receive(:instance_exec).with(options).and_yield
53+
subject.use :params_group, options
54+
end
55+
56+
it 'raises error when non-existent named param is called' do
57+
allow(Grape::DSL::Configuration).to receive(:stacked_hash_to_hash).and_return({})
58+
expect { subject.use :params_group }.to raise_error('Params :params_group not found!')
59+
end
4660
end
4761

4862
describe '#use_scope' do

0 commit comments

Comments
 (0)