Created
October 22, 2009 22:58
-
-
Save ono/216434 to your computer and use it in GitHub Desktop.
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
require File.dirname(__FILE__) + '/../spec_helper' | |
class Foo | |
def self.hello | |
"hello" | |
end | |
end | |
class FooBar < Foo | |
def self.konnichiwa | |
"konnichiwa" | |
end | |
end | |
describe '#mock' do | |
it "should be able to mock a class method" do | |
# ==== This succeeds. | |
mock(Foo).hello { "hello!" } | |
Foo.hello.should == "hello!" | |
end | |
it "should be able to mock a class method which will be executed by the subclass" do | |
# ==== This fails. | |
mock(Foo).hello { "hello!" } | |
FooBar.hello.should == "hello!" | |
end | |
it "should not affect from a previous example" do | |
# ==== This fails too. (remove '--reverse' from spec.opts and run after the above spec) | |
FooBar.hello.should == "hello" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment