File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ module DSL
5
5
module ParametersSpec
6
6
class Dummy
7
7
include Grape ::DSL ::Parameters
8
+ attr_accessor :api
8
9
9
10
def validate_attributes ( *args )
10
11
@validate_attributes = *args
@@ -41,8 +42,21 @@ def validates_reader
41
42
describe Parameters do
42
43
subject { ParametersSpec ::Dummy . new }
43
44
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
46
60
end
47
61
48
62
describe '#use_scope' do
You can’t perform that action at this time.
0 commit comments