Skip to content

Instantly share code, notes, and snippets.

@rubypanther
Created April 1, 2012 10:36
Show Gist options
  • Save rubypanther/2274375 to your computer and use it in GitHub Desktop.
Save rubypanther/2274375 to your computer and use it in GitHub Desktop.
An RSpec "undefined method" oddity
class UndefinedMethodOddity
def foo
bar 1
bar 2
end
def bar(arg)
end
end
describe UndefinedMethodOddity do
describe '#foo' do
it "correctly complaints 'expected: 1 time, received: 2 times'" do
subject.should_receive(:bar)
subject.foo
end
it "strangely complains about 'undefined method `bar' for #<UndefinedMethodOddity'" do
subject.stub(:bar)
subject.should_receive(:bar).with(1)
subject.foo
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment