@@ -64,8 +64,43 @@ class Dummy
64
64
expect ( app2 . inheritable_setting . to_hash [ :namespace_stackable ] ) . to eq ( :mount_path => [ '/app1' , '/app2' ] )
65
65
end
66
66
end
67
- xdescribe '.route' do
68
- it 'does some thing'
67
+
68
+ describe '.route' do
69
+ before do
70
+ allow ( subject ) . to receive ( :endpoints ) . and_return ( [ ] )
71
+ allow ( subject ) . to receive ( :route_end )
72
+ allow ( subject ) . to receive ( :reset_validations! )
73
+ end
74
+
75
+ it 'marks end of the route' do
76
+ expect ( subject ) . to receive ( :route_end )
77
+ subject . route ( :any )
78
+ end
79
+
80
+ it 'resets validations' do
81
+ expect ( subject ) . to receive ( :reset_validations! )
82
+ subject . route ( :any )
83
+ end
84
+
85
+ it 'defines a new endpoint' do
86
+ expect { subject . route ( :any ) }
87
+ . to change { subject . endpoints . count } . from ( 0 ) . to ( 1 )
88
+ end
89
+
90
+ it 'generates correct endpoint options' do
91
+ allow ( subject ) . to receive ( :route_setting ) . with ( :description ) . and_return ( fiz : 'baz' )
92
+ allow ( Grape ::DSL ::Configuration ) . to receive ( :stacked_hash_to_hash ) . and_return ( nuz : 'naz' )
93
+
94
+ expect ( Grape ::Endpoint ) . to receive ( :new ) do |inheritable_setting , endpoint_options |
95
+ puts endpoint_options
96
+ expect ( endpoint_options [ :method ] ) . to eq :get
97
+ expect ( endpoint_options [ :path ] ) . to eq '/foo'
98
+ expect ( endpoint_options [ :for ] ) . to eq subject
99
+ expect ( endpoint_options [ :route_options ] ) . to eq ( foo : 'bar' , fiz : 'baz' , params : { nuz : 'naz' } )
100
+ end . and_yield
101
+
102
+ subject . route ( :get , '/foo' , { foo : 'bar' } , &proc { } )
103
+ end
69
104
end
70
105
71
106
describe '.get' do
0 commit comments