[Rspec-devel] define_instance_method, stub_with, and mock_with

David Chelimsky dchelimsky at gmail.com
Mon Sep 4 19:03:09 EDT 2006

On 9/4/06, Jay Levitt <lists-rspec at shopwatch.org> wrote:
> David Chelimsky wrote:
> >> Also, FWIW, it sounds like Mocha is likely to become included in (or at
> >> least used by) Rails core:
> >>
> >> http://rubyforge.org/pipermail/mocha-developer/2006-September/000017.html
> > I think it is very relevant. I've been playing around w/ using Mocha
> > and Stubba from rspec. Haven't gotten it to work the way I want to
> > yet, but if we can tap into a solid mock framework that someone else
> > is maintaining, why not? The catch would be that the syntax for mocha
> > is slightly different - using "expects" instead of "should_receive".
> > But a simple search and replace should fix that - no? There are a
> > couple of others, like "returns" instead of "and_return", etc.
> So would you propose wrapping and aliasing the mocha methods, or trying
> to convice James to include those aliases for rspec use?

I'm more inclined to deprecate rspec's mocking framework. We'd keep it
alive, but frozen, for some time to avoid forcing transition - but if
we're going to plug in other frameworks then I see little value in
wrapping them.

> > What is important to me is that whatever mock framework we use is
> > seamlessly integrated, auto-verified, etc. If mocha works its way into
> > rails, it will implicitly become somewhat of a standard. And while
> > rspec's expectation API and context/specify DSL offer something that
> > feels different from test/unit, the mock framework really doesn't
> > offer anything worthy of maintaining yet another framework.
> I completely agree.  I'd rather see rspec stick to the things that make
> it unique.  But then, I almost always wish people working on a library
> would simply merge it with that other library, and that so rarely
> happens...  I'm a big fan of integration.
> Personally, I think that while mocha may not have picked the verbs you'd
> pick for rspec, the overall syntax blends nicely with rspec, and I'd
> rather see rspec's mocks be cut-and-paste compatible with the many
> examples of mocking that are likely to pop up if it gets included in core.

I agree.

> And I am simply loving:
>    setup do
>      Time.stubs(:now).returns(Time.at(1))

Yeah, yeah, yeah. OK.


> Jay
> >
> > Any other opinions?
> >
> > David
> > _______________________________________________
> > Rspec-devel mailing list
> > Rspec-devel at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-devel
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel

More information about the Rspec-devel mailing list