diff options
-rw-r--r-- | lib/rack/showexceptions.rb | 2 | ||||
-rw-r--r-- | test/spec_showexceptions.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/rack/showexceptions.rb b/lib/rack/showexceptions.rb index 60999e64..44ee5678 100644 --- a/lib/rack/showexceptions.rb +++ b/lib/rack/showexceptions.rb @@ -47,7 +47,7 @@ module Rack end def prefers_plaintext?(env) - !accepts_html(env) + !accepts_html?(env) end def accepts_html?(env) diff --git a/test/spec_showexceptions.rb b/test/spec_showexceptions.rb index 7d50c59f..a4ccef91 100644 --- a/test/spec_showexceptions.rb +++ b/test/spec_showexceptions.rb @@ -82,4 +82,17 @@ describe Rack::ShowExceptions do res.should =~ /ShowExceptions/ res.should =~ /unknown location/ end + + it "knows to prefer plaintext for non-html" do + # We don't need an app for this + exc = Rack::ShowExceptions.new(nil) + + [ + [{ "HTTP_ACCEPT" => "text/plain" }, true], + [{ "HTTP_ACCEPT" => "text/foo" }, true], + [{ "HTTP_ACCEPT" => "text/html" }, false] + ].each do |env, expected| + assert_equal(expected, exc.prefers_plaintext?(env)) + end + end end |