and_call_original doesn't work with module methods singletonized with "extend self" #212

Closed
evanbattaglia opened this Issue Jan 4, 2013 · 2 comments

Projects

None yet

2 participants

The following spec is not working, giving an undefined method 'foo' for Foo:Module error:

module Foo
  extend self
  def foo
    5
  end
end

describe 'Foo' do
  describe '.foo' do
    it 'works' do
      Foo.should_receive(:foo).and_call_original
      Foo.foo.should == 5
    end
  end
end

However, when I change def foo to def self.foo (as in cuke call_original.feature) it works (with or without the extend self).

@myronmarston myronmarston was assigned Jan 4, 2013
Owner

@evanbattaglia -- want to give my fix in #213 a try? I believe it should fix your problem.

That fixes it, thanks!

@myronmarston myronmarston added a commit that referenced this issue Jan 5, 2013
@myronmarston myronmarston Fix `and_call_original` so that it looks for the method in all ancestors
...including those mixed into the singleton class (i.e.
via a module extended onto an object instance).

Fixes #212.
14ae958
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment