Permalink
Browse files

make sure route returns the signature

  • Loading branch information...
1 parent df0d9f4 commit af6b4c5367f0e05c047186787fe961d3c195c5c8 @rkh rkh committed Aug 17, 2011
Showing with 16 additions and 1 deletion.
  1. +3 −1 lib/sinatra/base.rb
  2. +13 −0 test/routing_test.rb
View
@@ -1149,8 +1149,10 @@ def route(verb, path, options={}, &block)
# Because of self.options.host
host_name(options.delete(:host)) if options.key?(:host)
enable :empty_path_info if path == "" and empty_path_info.nil?
- (@routes[verb] ||= []) << compile!(verb, path, block, options)
+ signature = compile!(verb, path, block, options)
+ (@routes[verb] ||= []) << signature
invoke_hook(:route_added, verb, path, block)
+ signature
end
def invoke_hook(name, *args)
View
@@ -1080,4 +1080,17 @@ def authorize(username, password)
assert ok?
assert_body 'hello'
end
+
+ it 'returns the route signature' do
+ signature = list = nil
+
+ mock_app do
+ signature = post('/') { }
+ list = routes['POST']
+ end
+
+ assert_equal Array, signature.class
+ assert_equal 4, signature.length
+ assert list.include?(signature)
+ end
end

0 comments on commit af6b4c5

Please sign in to comment.