1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/sinatra-contrib/spec/multi_route_spec.rb

45 lines
1,009 B
Ruby
Raw Normal View History

2011-09-04 21:13:27 -04:00
require 'backports'
require_relative 'spec_helper'
describe Sinatra::MultiRoute do
before do
count = 0
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 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