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

46 lines
1,014 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
2011-09-04 21:26:48 -04:00
set(:some_condition) { |_| count += 1 }
2011-09-04 21:13:27 -04: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
2012-12-09 11:35:15 -05:00
it 'supports multiple routes' do
2011-09-04 21:13:27 -04:00
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
2012-12-09 11:35:15 -05:00
it 'supports multiple verbs' do
2011-09-04 21:13:27 -04:00
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
2012-12-09 11:35:15 -05:00
end