Reputation: 3615
reduced code:
class Object
def foo
(bar / 100).round(2)
end
def bar
self.some_integer
end
end
I wanted to test that foo calls bar so my spec looks like this
it 'calls #bar upon self' do
expect(@object).to receive(:bar)
@object.foo
end
Unfortunately the spec then fails because when calling @object.foo
the #bar
is nil and fails on the division. Its impossible that #bar
returns a nil value thats ensured before.
How do I test this correctly?
Upvotes: 0
Views: 71