Hello RSpec folks,
I've only been introduced to the world of mock objects since Wednesday
of last week, so go easy on me if I come off as ignorant. :P

So, I'm a big fan of testing, especially since it has really helped to
do refactoring in the past. But, I'm running into an issue that I'm
hoping could be cleared up. Let's say that I have some code like the
following:

mock_engine = mock("Engine")
mock_engine.should_receive(:ignite)
car = Car.new(mock_engine)
car.start

Internally, the car class calls "ignite" on the engine that was passed
to the constructor. We run the spec, everything is green. So far, so
good.

Now, here's what I don't understand: suppose I refactor the Engine class
and rename the "ignite" method to "turn_on". If I re-run the example
from above, the test is still green - but it shouldn't be, since the
"ignite" method doesn't exist on the Engine class anymore.

So I'm wondering...what am I doing wrong? I feel like my tests should
help catch these sorts of things when I do a refactoring - my hunch is
that I'm missing a step here.

All comments are welcomed and appreciated! :)
-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to