test/system/rack_tests.rb in deas-0.11.0 vs test/system/rack_tests.rb in deas-0.12.0
- old
+ new
@@ -2,20 +2,22 @@
require 'assert-rack-test'
require 'deas'
module Deas
- class RackTests < Assert::Context
+ class RackTestContext < Assert::Context
include Assert::Rack::Test
+ def app; @app; end
+ end
+
+ class RackTests < RackTestContext
desc "a Deas server rack app"
setup do
@app = DeasTestServer.new
end
- def app; @app; end
-
should "return a 200 response with a GET to '/show'" do
get '/show', 'message' => 'this is a test'
expected_body = "show page: this is a test\n" \
"Stuff: Show Info\n"
@@ -117,9 +119,33 @@
assert_equal 'Logger', @data['logger_class_name']
assert_equal 'GET', @data['request_method']
assert_equal 'Content-Type', @data['response_firstheaderval']
assert_equal 'something', @data['params_a_param']
assert_equal '{}', @data['session_inspect']
+ end
+
+ end
+
+ class ShowExceptionsTests < RackTestContext
+ desc "a Deas server rack app with show exceptions enabled"
+ setup do
+ @app = DeasDevServer.new
+ end
+
+ should "return a text/plain body when a 404 occurs" do
+ get '/not_defined'
+
+ assert_equal 404, last_response.status
+ assert_equal "text/plain", last_response.headers['Content-Type']
+ assert_match "Sinatra::NotFound: Sinatra::NotFound", last_response.body
+ end
+
+ should "return a text/plain body when an exception occurs" do
+ get '/error'
+
+ assert_equal 500, last_response.status
+ assert_equal "text/plain", last_response.headers['Content-Type']
+ assert_match "RuntimeError: test", last_response.body
end
end
end