set RACK_ENV in test/helper.rb to ensure sane environment
This commit is contained in:
parent
3b9578f4dd
commit
f3ce689965
|
@ -1,3 +1,5 @@
|
||||||
|
ENV['RACK_ENV'] = 'test'
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'rack'
|
require 'rack'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
|
|
|
@ -44,15 +44,19 @@ class RoutingTest < Test::Unit::TestCase
|
||||||
assert_equal 404, status
|
assert_equal 404, status
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets the content-type to text/html in the default 404 handler" do
|
it "overrides the content-type in error handlers" do
|
||||||
mock_app {
|
mock_app {
|
||||||
before { content_type 'text/plain' }
|
before { content_type 'text/plain' }
|
||||||
|
error Sinatra::NotFound do
|
||||||
|
content_type "text/html"
|
||||||
|
"<h1>Not Found</h1>"
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
get '/foo'
|
get '/foo'
|
||||||
assert_equal 404, status
|
assert_equal 404, status
|
||||||
assert_equal 'text/html', response["Content-Type"]
|
assert_equal 'text/html', response["Content-Type"]
|
||||||
assert body.include?("Sinatra doesn't know this ditty")
|
assert_equal "<h1>Not Found</h1>", response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'takes multiple definitions of a route' do
|
it 'takes multiple definitions of a route' do
|
||||||
|
|
Loading…
Reference in New Issue