Created
February 16, 2012 20:44
-
-
Save dlchet/1847708 to your computer and use it in GitHub Desktop.
how to use rspec stubbing to first raise, then return
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
module Test | |
def catcher | |
begin | |
pp Foo.bar | |
rescue Exception | |
pp "errored" | |
end | |
end | |
end |
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
include Test | |
class Foo; end | |
describe "testing" do | |
it "should work" do | |
@counter = 0 | |
Foo.stub(:bar) do | |
@counter += 1 | |
pp @counter | |
raise Exception if @counter < 2 | |
"hello" | |
end | |
catcher | |
catcher | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment