[rspec-users] Mocks and Refactoring - doing it wrong?

Scott Taylor mailing_lists at railsnewbie.com
Thu Oct 30 02:27:24 EDT 2008

On Oct 30, 2008, at 2:17 AM, David Chelimsky wrote:

> On Thu, Oct 30, 2008 at 1:14 AM, Scott Taylor
> <mailing_lists at railsnewbie.com> wrote:
>> On Oct 30, 2008, at 2:01 AM, Sebastian W. wrote:
>>> Hi Scott,
>>> Cool - I see what you're saying here. The only thing that I'm a bit
>>> confused still is that it seems like, at least if your system is
>>> starting to get larger, you'd really *want* your fast unit test to  
>>> help
>>> you catch API changes like this to help you make updates faster.
>>> Having to run a suite of more expensive integration tests just to  
>>> catch
>>> API changes seems a little funny. But I guess I'm also hoping that
>>> there's some way for the mocks to help with that sort of thing -  
>>> it's my
>>> understanding that some other frameworks out there help you with  
>>> that
>>> sort of stuff. One example mentioned to me was JMock -- granted,  
>>> that's
>>> Java, but still - if it's possible in Java, Ruby should be able to  
>>> do it
>>> too. :P
>> Most certainly.
>> David, et. all:
>> Why don't we have a partial mock which will raise an error (or at  
>> least a
>> warning) when stubbing an object who's class doesn't respond_to?  
>> the method
>> given?  I feel like this sort of simple dependency has been brought  
>> up 1000
>> times on the list before, but never been explicitly stated.
>> WDYT?
> This has come up before.
> The problem is that we're dealing with a dynamic language and the
> class definition may or may not include the definition of that method
> at the point that the mock framework would do such an evaluation,
> especially if thing are getting mocked that might otherwise be loading
> modules and extending behaviour.
> I'd rather have it be a known problem, but a consistent problem, then
> a partially solved problem that will inevitably cause more pain that
> it does today :)

Yeah, that's a good point.

I wonder if possibly passing some sort of flag to the stub, which is  
off by default (or on) might solve this problem.


More information about the rspec-users mailing list