summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2018-04-14 15:27:50 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2018-04-14 15:27:50 -0700
commita12dccf51d1463c921748a0a4ae5f1388b4f5b1d (patch)
treed4d13af2facc25d33bcca2c15478a3c248aa4c5e /test
parentdc204b1b3cf6dc7d525a1ee7852531cfc14d6ec2 (diff)
parent17fb74d204198bfbd47bb6776beb11ee828eb2c2 (diff)
downloadrack-a12dccf51d1463c921748a0a4ae5f1388b4f5b1d.tar.gz
Merge branch 'patch-1' of https://github.com/jkowens/rack into jkowens-patch-1
* 'patch-1' of https://github.com/jkowens/rack: Override template using #template method Allow subclasses to override TEMPLATE constant
Diffstat (limited to 'test')
-rw-r--r--test/spec_show_exceptions.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/spec_show_exceptions.rb b/test/spec_show_exceptions.rb
index 40d3b586..eca46c71 100644
--- a/test/spec_show_exceptions.rb
+++ b/test/spec_show_exceptions.rb
@@ -79,4 +79,26 @@ describe Rack::ShowExceptions do
assert_match(res, /ShowExceptions/)
assert_match(res, /unknown location/)
end
+
+ it "allows subclasses to override template" do
+ c = Class.new(Rack::ShowExceptions) do
+ TEMPLATE = ERB.new("foo")
+
+ def template
+ TEMPLATE
+ end
+ end
+
+ app = lambda { |env| raise RuntimeError, "", [] }
+
+ req = Rack::MockRequest.new(
+ Rack::Lint.new c.new(app)
+ )
+
+ res = req.get("/", "HTTP_ACCEPT" => "text/html")
+
+ res.must_be :server_error?
+ res.status.must_equal 500
+ res.body.must_equal "foo"
+ end
end