sinatra/sinatra-contrib/spec/multi_route_spec.rb

45 lines
1013 B
Ruby
Raw Normal View History

2011-09-05 01:13:27 +00:00
require 'backports'
require_relative 'spec_helper'
describe Sinatra::MultiRoute do
before do
count = 0
mock_app do
2011-09-05 01:26:48 +00:00
set(:some_condition) { |_| count += 1 }
2011-09-05 01:13:27 +00:00
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 multpile routes' do
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
end
it 'supports multpile verbs' do
post('/').should be_ok
body.should be == 'verb'
put('/').should be_ok
body.should be == 'verb'
end
it 'takes symbols as verbs' do
get('/baz').should be_ok
body.should be == 'symbol as verb'
end
end