Created
November 23, 2010 15:13
-
-
Save RobertDober/711904 to your computer and use it in GitHub Desktop.
We are setting an instance variable in a stub, easy but a little bit doubtful.
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
# This is an adapted example from http://relishapp.com/rspec/rspec-mocks/v/2-1/dir/stubs/stub-with-substitute-implementation | |
describe "a stubbed implementation" do | |
it "works" do | |
object = Object.new | |
object.stub(:foo) do |arg| | |
if arg == :set then | |
@x = 42 | |
elsif arg == :inc | |
@x += 1 | |
end | |
end | |
object.foo(:set).should == 42 | |
object.foo(:inc).should == 43 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment