@@ -92,7 +92,7 @@ def app; subject end
9292 subject . version :v1
9393
9494 subject . namespace :awesome do
95- compile_path ( 'hello' ) . should == '/rad/:version/awesome/hello'
95+ compile_path ( 'hello' ) . should == '/rad/:version/awesome/hello(.:format) '
9696 end
9797 end
9898
@@ -117,9 +117,9 @@ def app; subject end
117117 it 'should be callable with nil just to push onto the stack' do
118118 subject . namespace do
119119 version 'v2'
120- compile_path ( 'hello' ) . should == '/:version/hello'
120+ compile_path ( 'hello' ) . should == '/:version/hello(.:format) '
121121 end
122- subject . send ( :compile_path , 'hello' ) . should == '/hello'
122+ subject . send ( :compile_path , 'hello' ) . should == '/hello(.:format) '
123123 end
124124
125125 %w( group resource resources ) . each do |als |
@@ -159,6 +159,26 @@ def app; subject end
159159 get '/def'
160160 last_response . body . should == 'foo'
161161 end
162+
163+ it 'should allow for format' do
164+ subject . get ( "/abc" ) do
165+ "json"
166+ end
167+
168+ get '/abc.json'
169+ last_response . body . should == '"json"'
170+ end
171+
172+ it 'should allow for format in namespace with no path' do
173+ subject . namespace :abc do
174+ get do
175+ "json"
176+ end
177+ end
178+
179+ get '/abc.json'
180+ last_response . body . should == '"json"'
181+ end
162182
163183 it 'should allow for multiple verbs' do
164184 subject . route ( [ :get , :post ] , '/abc' ) do
@@ -340,4 +360,4 @@ def two
340360 last_response . status . should == 200
341361 end
342362 end
343- end
363+ end
0 commit comments