Sha256: 5082a9280e3b0e108c3110760ff0c058cd014d06a9e77b034300552af8621759
Contents?: true
Size: 822 Bytes
Versions: 8
Compression:
Stored size: 822 Bytes
Contents
require "examples/example_helper" module RR describe Double, "#bind with an existing method" do before do @space = Space.new @object = Object.new @method_name = :foobar def @object.foobar; :original_foobar; end @object.methods.should include(@method_name.to_s) @double = Double.new(@space, @object, @method_name) end it "overrides the original method with the double's dispatching methods" do @object.respond_to?(:__rr__foobar).should == false @double.bind @object.respond_to?(:__rr__foobar).should == true rr_foobar_called = false (class << @object; self; end).class_eval do define_method :__rr__foobar do rr_foobar_called = true end end rr_foobar_called.should == false @object.foobar rr_foobar_called.should == true end end end
Version data entries
8 entries across 8 versions & 1 rubygems