[rspec-users] [newbie]: How to test for operations inside a block?
CarmineM
carmine.moleti at gmail.com
Tue Sep 23 06:39:13 EDT 2008
I came up with this code:
def mock_result(stubs = {})
@result ||= mock('Object', stubs)
end
describe "being an administrator" do
it "should create a new user using OpenID authentication" do
@controller.should_receive(:authenticate_with_open_id).with(@identity_url,
anything()).and_yield(mock_result(:successful? => true),
@identity_url, mock_registration)
User.should_receive(:create_with_role).and_return(@user =
create_operator_user)
do_verb
response.should redirect_to(users_path)
end
end
which doesn't give any error and seems pretty fine to me. Is this the
way it is meant to be done?
Thanks for your help
More information about the rspec-users
mailing list