Permalink
Browse files

Replace Sinatra::Test by Rack::Test

  • Loading branch information...
1 parent ce83fa2 commit afed1e0b619dc91891a0e55e23d7565f8017331e @sr sr committed Mar 19, 2009
Showing with 11 additions and 11 deletions.
  1. +11 −11 test/authorization_test.rb
View
@@ -1,5 +1,5 @@
require "test/unit"
-require "sinatra/test"
+require "rack/test"
require "context"
require "pending"
@@ -25,7 +25,7 @@ def authorization_realm
class SinatraAuthorizationTest < Test::Unit::TestCase
before do
- @session = Sinatra::TestHarness.new(AuthorizationApp)
+ @session = Rack::Test::Session.new(AuthorizationApp)
end
def basic_auth(user="user", password="test")
@@ -35,9 +35,9 @@ def basic_auth(user="user", password="test")
end
it "is authorized with correct credentials" do
- @session.get "/", :env => basic_auth
- assert_equal 200, @session.status
- assert_equal "Welcome in protected zone", @session.body
+ @session.get "/", {}, basic_auth
+ assert_equal 200, @session.last_response.status
+ assert_equal ["Welcome in protected zone"], @session.last_response.body
end
it "sets REMOTE_USER" do
@@ -46,21 +46,21 @@ def basic_auth(user="user", password="test")
it "is unauthorized without credentials" do
@session.get "/"
- assert_equal 401, @session.status
+ assert_equal 401, @session.last_response.status
end
it "is unauthorized with incorrect credentials" do
- @session.get "/", :env => basic_auth("evil", "wrong")
- assert_equal 401, @session.status
+ @session.get "/", {}, basic_auth("evil", "wrong")
+ assert_equal 401, @session.last_response.status
end
it "returns specified realm" do
@session.get "/"
- assert_equal %Q(Basic realm="Move on"), @session["WWW-Authenticate"]
+ assert_equal %Q(Basic realm="Move on"), @session.last_response["WWW-Authenticate"]
end
it "returns a 400, Bad Request if not basic auth" do
- @session.get "/", :env => { "HTTP_AUTHORIZATION" => "Foo bar" }
- assert_equal 400, @session.status
+ @session.get "/", {}, { "HTTP_AUTHORIZATION" => "Foo bar" }
+ assert_equal 400, @session.last_response.status
end
end

0 comments on commit afed1e0

Please sign in to comment.