Permalink
Browse files

Merge pull request #80 from kytrinyx/refactor-multi-route-specs

Refactor multi-route specs
  • Loading branch information...
2 parents cf4f566 + 5a1d45e commit 65ffe0bda35107e42318d68a9e6c1775bec6c6c9 @TrevorBramble TrevorBramble committed Feb 19, 2013
Showing with 25 additions and 10 deletions.
  1. +25 −10 spec/multi_route_spec.rb
View
@@ -2,43 +2,58 @@
require_relative 'spec_helper'
describe Sinatra::MultiRoute do
- before do
- count = 0
+
+ it 'does not break normal routing' do
mock_app do
- set(:some_condition) { |_| count += 1 }
register Sinatra::MultiRoute
get('/') { 'normal' }
- get('/foo', '/bar', :some_condition => true) { 'paths' }
- route('PUT', 'POST', '/') { 'verb' }
- route(:get, '/baz') { 'symbol as verb' }
end
- @count = count
- end
- it 'does still allow normal routing' do
get('/').should be_ok
body.should be == 'normal'
end
it 'supports multiple routes' do
+ mock_app do
+ register Sinatra::MultiRoute
+ get('/foo', '/bar') { 'paths' }
+ end
+
get('/foo').should be_ok
body.should be == 'paths'
get('/bar').should be_ok
body.should be == 'paths'
end
it 'triggers conditions' do
- @count.should be == 4
+ count = 0
+ mock_app do
+ register Sinatra::MultiRoute
+ set(:some_condition) { |_| count += 1 }
+ get('/foo', '/bar', :some_condition => true) { 'paths' }
+ end
+
+ count.should be == 4
end
it 'supports multiple verbs' do
+ mock_app do
+ register Sinatra::MultiRoute
+ route('PUT', 'POST', '/') { 'verb' }
+ end
+
post('/').should be_ok
body.should be == 'verb'
put('/').should be_ok
body.should be == 'verb'
end
it 'takes symbols as verbs' do
+ mock_app do
+ register Sinatra::MultiRoute
+ route(:get, '/baz') { 'symbol as verb' }
+ end
+
get('/baz').should be_ok
body.should be == 'symbol as verb'
end

0 comments on commit 65ffe0b

Please sign in to comment.