Created
May 12, 2009 15:53
-
-
Save dsabanin/110550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mocks a request to OpenID server with given response status. | |
# If you give it a hash of args as a third argument, it will act | |
# like information about user transmitted from OpenID server. | |
class ActiveSupport::TestCase | |
# Example: | |
# mock_openid_response("http://identity.url", OpenID::Consumer::SUCCESS, | |
# 'fullname' => 'Joe Black', | |
# 'email' => 'joe.black@gmail.com', | |
# 'nickname' => 'joeeeey') | |
# # naming of the params is important - we're emulating request made by OpenID server | |
# post :create, :openid_identifier => "http://identity.url", | |
# :open_id_complete => true | |
def mock_openid_response(identity_url, status, user_data={}) | |
response = stub(:status => status, :display_identifier => identity_url) | |
@controller.stubs(:timeout_protection_from_identity_server).returns(response) | |
# Mock data response from openid server with login info | |
[ OpenID::SReg::Response, OpenID::AX::FetchResponse ].each do |data_response| | |
resp = stub(:data => user_data) | |
data_response.stubs(:from_success_response).returns(resp) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment