Skip to content

Instantly share code, notes, and snippets.

@ueno1969
Created May 31, 2012 06:02
Show Gist options
  • Save ueno1969/2841418 to your computer and use it in GitHub Desktop.
Save ueno1969/2841418 to your computer and use it in GitHub Desktop.
RRのmockでtapを使ったら、うまく動かなかった
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
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