Created
May 31, 2012 06:02
-
-
Save ueno1969/2841418 to your computer and use it in GitHub Desktop.
RRのmockでtapを使ったら、うまく動かなかった
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 'rspec' | |
require 'rr' | |
RSpec.configure do |config| | |
config.mock_with :rr | |
end | |
class Sample | |
def self.call | |
1 | |
end | |
end | |
describe "stub test" do | |
it "not use stub" do | |
Sample.call.should == 1 | |
end | |
it "use stub and no tap" do | |
stub(Sample).call { 2 } | |
Sample.call.should == 2 | |
end | |
it "use stub with tap" do | |
stub(Sample).tap do |m| | |
# not eval hear! | |
m.call { 3 } | |
end | |
Sample.call.should == 3 | |
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
rrのmockに対してtapを使ったら、動いていなかった. | |
mock(Foo)したものが普通のObjectでないので、tapも普通に使えないわけで... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment