From f3ce6899652af722c69dd6ffdc11829251251e02 Mon Sep 17 00:00:00 2001 From: Ryan Tomayko Date: Sat, 25 Apr 2009 09:17:11 -0700 Subject: [PATCH] set RACK_ENV in test/helper.rb to ensure sane environment --- test/helper.rb | 2 ++ test/routing_test.rb | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 153b62de..ed12d982 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,3 +1,5 @@ +ENV['RACK_ENV'] = 'test' + begin require 'rack' rescue LoadError diff --git a/test/routing_test.rb b/test/routing_test.rb index 3cc16282..0c315d10 100644 --- a/test/routing_test.rb +++ b/test/routing_test.rb @@ -44,15 +44,19 @@ class RoutingTest < Test::Unit::TestCase assert_equal 404, status 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 { before { content_type 'text/plain' } + error Sinatra::NotFound do + content_type "text/html" + "

Not Found

" + end } get '/foo' assert_equal 404, status assert_equal 'text/html', response["Content-Type"] - assert body.include?("Sinatra doesn't know this ditty") + assert_equal "

Not Found

", response.body end it 'takes multiple definitions of a route' do