Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improved tests

  • Loading branch information...
commit efbedfa728c1c144c2e0ecdb5c08174053219cf9 1 parent b85f587
Michael Reinsch mreinsch authored
8 test/acts_as_authentic_test.rb
View
@@ -14,7 +14,7 @@ def test_password_not_required_on_create
user.email = "a@a.com"
user.openid_identifier = "https://me.yahoo.com/a/9W0FJjRj0o981TMSs0vqVxPdmMUVOQ--"
assert !user.save {} # because we are redirecting, the user was NOT saved
- assert redirecting_to_yahoo?
+ assert_redirecting_to_yahoo "for_model"
end
def test_password_required_on_create
@@ -69,7 +69,7 @@ def test_updating_with_openid
ben = users(:ben)
ben.openid_identifier = "https://me.yahoo.com/a/9W0FJjRj0o981TMSs0vqVxPdmMUVOQ--"
assert !ben.save {} # because we are redirecting
- assert redirecting_to_yahoo?
+ assert_redirecting_to_yahoo "for_model"
end
def test_updating_without_openid
@@ -78,14 +78,14 @@ def test_updating_without_openid
ben.password = "test"
ben.password_confirmation = "test"
assert ben.save
- assert !redirecting_to_yahoo?
+ assert_not_redirecting
end
def test_updating_without_validation
ben = users(:ben)
ben.openid_identifier = "https://me.yahoo.com/a/9W0FJjRj0o981TMSs0vqVxPdmMUVOQ--"
assert ben.save(false)
- assert !redirecting_to_yahoo?
+ assert_not_redirecting
end
def test_updating_without_a_block
4 test/session_test.rb
View
@@ -20,13 +20,13 @@ def test_validate_openid_error
def test_validate_by_nil_openid_identifier
session = UserSession.new
assert !session.save
- assert !redirecting_to_yahoo?
+ assert_not_redirecting
end
def test_validate_by_correct_openid_identifier
session = UserSession.new
session.openid_identifier = "https://me.yahoo.com/a/9W0FJjRj0o981TMSs0vqVxPdmMUVOQ--"
assert !session.save
- assert redirecting_to_yahoo?
+ assert_redirecting_to_yahoo "for_session"
end
end
13 test/test_helper.rb
View
@@ -105,8 +105,13 @@ def create_controller
Authlogic::ControllerAdapters::RailsAdapter.new(c)
end
- def redirecting_to_yahoo?
- expected = "OpenID identifier=\"https://me.yahoo.com/a/9W0FJjRj0o981TMSs0vqVxPdmMUVOQ--\", return_to=\"http://test.host/?for_model=1\", optional=\"\", method=\"post\", required=\"\""
- @response.headers["WWW-Authenticate"] == expected
+ def assert_redirecting_to_yahoo(for_param)
+ [ /^OpenID identifier="https:\/\/me.yahoo.com\/a\/9W0FJjRj0o981TMSs0vqVxPdmMUVOQ--"/,
+ /return_to=\"http:\/\/test.host\/\?#{for_param}=1"/,
+ /method="post"/ ].each {|p| assert_match p, @response.headers["WWW-Authenticate"]}
end
-end
+
+ def assert_not_redirecting
+ assert ! @response.headers["WWW-Authenticate"]
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.