here is the spec for the two-step openid authentication process in a rails controller.
it "should login with a valid openid credential" do my_openid = "http://identityprovider/username" # mock Openid model oid = mock_model(Openid) user = mock_model(User) oid.should_receive(:user).and_return(user) Openid.should_receive(:find_by_openid).with(my_openid).and_return(oid) # mock OpenID::Response oid_response = mock("OpenID::Response") oid_response.should_receive(:status).and_return(OpenID::Consumer::SUCCESS) oid_response.should_receive(:identity_url).and_return(my_openid) # mock OpenID::Consumer consumer = mock("OpenID::Consumer") consumer.should_receive(:complete).and_return(oid_response) # mock the lib/OpenidUtility controller.should_receive(:consumer).and_return(consumer) controller.should_receive(:current_user=).with(user) get 'complete' response.should redirect_to("http://test.host/welcome/login") end