Skip to content

Instantly share code, notes, and snippets.

@Haegin
Created February 14, 2013 10:48
Show Gist options
  • Save Haegin/4951986 to your computer and use it in GitHub Desktop.
Save Haegin/4951986 to your computer and use it in GitHub Desktop.
I'm trying to test a code path that is hit when a function I'm calling raises an OAuth2::Error exception.
https://github.com/intridea/oauth2/blob/master/lib/oauth2/error.rb
OAuth2::Error takes in a response as a parameter but I really don't care about this and just want to mock this all out.
Currently I have the following:
setup do
@thing = flexmock(Thing.new(c))
@thing.should_receive('client').and_raise(OAuth2::Error)
end
should "handle an oAuth error correctly" do
@thing.do_fetch_token('arg') # this should raise the error, I'll wrap it in a should raise thing once it's working
end
Currently it throws a hissy fit because the wrong arguments are getting passed to OAuth2::Error. How can I fix this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment