mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Move a few specs out of base_test and into more appropriate tests
This commit is contained in:
parent
a9e9f00240
commit
6fd8aaadd1
3 changed files with 35 additions and 36 deletions
|
@ -42,40 +42,4 @@ describe 'Sinatra::Base' do
|
|||
assert response.ok?
|
||||
assert_equal 'Goodbye World', response.body
|
||||
end
|
||||
|
||||
it 'can take multiple definitions of a route' do
|
||||
app = mock_app {
|
||||
user_agent(/Foo/)
|
||||
get '/foo' do
|
||||
'foo'
|
||||
end
|
||||
|
||||
get '/foo' do
|
||||
'not foo'
|
||||
end
|
||||
}
|
||||
|
||||
request = Rack::MockRequest.new(app)
|
||||
response = request.get('/foo', 'HTTP_USER_AGENT' => 'Foo')
|
||||
assert response.ok?
|
||||
assert_equal 'foo', response.body
|
||||
|
||||
request = Rack::MockRequest.new(app)
|
||||
response = request.get('/foo')
|
||||
assert response.ok?
|
||||
assert_equal 'not foo', response.body
|
||||
end
|
||||
|
||||
it "makes redirecting back pretty" do
|
||||
app = mock_app {
|
||||
get '/foo' do
|
||||
redirect back
|
||||
end
|
||||
}
|
||||
|
||||
request = Rack::MockRequest.new(app)
|
||||
response = request.get('/foo', 'HTTP_REFERER' => 'http://github.com')
|
||||
assert response.redirect?
|
||||
assert_equal "http://github.com", response.location
|
||||
end
|
||||
end
|
||||
|
|
|
@ -394,6 +394,20 @@ describe 'Helpers#etag' do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Helpers#back' do
|
||||
it "makes redirecting back pretty" do
|
||||
mock_app {
|
||||
get '/foo' do
|
||||
redirect back
|
||||
end
|
||||
}
|
||||
|
||||
get '/foo', {}, 'HTTP_REFERER' => 'http://github.com'
|
||||
assert redirect?
|
||||
assert_equal "http://github.com", response.location
|
||||
end
|
||||
end
|
||||
|
||||
module HelperOne; def one; '1'; end; end
|
||||
module HelperTwo; def two; '2'; end; end
|
||||
|
||||
|
|
|
@ -44,6 +44,27 @@ describe "Routing" do
|
|||
assert_equal 404, status
|
||||
end
|
||||
|
||||
it 'takes multiple definitions of a route' do
|
||||
mock_app {
|
||||
user_agent(/Foo/)
|
||||
get '/foo' do
|
||||
'foo'
|
||||
end
|
||||
|
||||
get '/foo' do
|
||||
'not foo'
|
||||
end
|
||||
}
|
||||
|
||||
get '/foo', {}, 'HTTP_USER_AGENT' => 'Foo'
|
||||
assert ok?
|
||||
assert_equal 'foo', body
|
||||
|
||||
get '/foo'
|
||||
assert ok?
|
||||
assert_equal 'not foo', body
|
||||
end
|
||||
|
||||
it "exposes params with indifferent hash" do
|
||||
mock_app {
|
||||
get '/:foo' do
|
||||
|
|
Loading…
Reference in a new issue