test/system/rack_tests.rb in deas-0.31.0 vs test/system/rack_tests.rb in deas-0.32.0
- old
+ new
@@ -1,9 +1,10 @@
require 'assert'
-require 'assert-rack-test'
require 'deas'
+require 'assert-rack-test'
+
module Deas
class RackTestsContext < Assert::Context
include Assert::Rack::Test
@@ -18,12 +19,11 @@
should "return a 200 response with a GET to '/show'" do
get '/show', 'message' => 'this is a test'
assert_equal 200, last_response.status
- exp = "this is a test"
- assert_equal exp, last_response.body
+ assert_equal "this is a test", last_response.body
end
should "set the content type appropriately" do
get '/show'
assert_equal 'text/html;charset=utf-8', last_response.headers['Content-Type']
@@ -42,10 +42,23 @@
get '/show-headers-text'
assert_equal 'text/plain', last_response.headers['Content-Type']
end
+ should "render different handlers for the same meth/path based on the type" do
+ get '/req-type-show/regular', 'message' => 'this is a test request'
+ assert_equal 200, last_response.status
+ assert_equal "this is a test request", last_response.body
+
+ get '/req-type-show/mobile', 'message' => 'this is a test request'
+ assert_equal 200, last_response.status
+ assert_equal "[MOBILE] this is a test request", last_response.body
+
+ get '/req-type-show/other', 'message' => 'this is a test request'
+ assert_equal 404, last_response.status
+ end
+
should "allow halting with a custom response" do
get '/halt', 'with' => 234
assert_equal 234, last_response.status
end
@@ -113,10 +126,9 @@
class HandlerTests < RackTests
desc "handler"
setup do
get 'handler/tests?a-param=something'
-
@data_inspect = last_response.body
end
should "be able to access sinatra call data" do
exp = {