[mocha-developer] Mocking system/`

Kevin Clark kevin.clark at gmail.com
Tue Jun 12 11:08:00 EDT 2007

Well, in the parse tree both %x and `` become an xstr, but I _thought_
those became a method dispatch. Maybe it happens in the C and so can't
be intercepted.

On 6/12/07, Paul Battley <pbattley at gmail.com> wrote:
> On 12/06/07, jpywtora at calpoly.edu <jpywtora at calpoly.edu> wrote:
> > Great; However, I was hoping to see how to mock the backtics, any ideas?
> >
> > Object.any_instance.expects(:`).with("ls")   # my guess, but is wrong
> I don't think it's possible. `` (or %x) isn't a normal message - it's
> a language construct of its own. (Sorry for the vague, hand-waving
> explanation!)
> A more verbose but more flexible alternative might be to use popen or
> open3 in your code instead of backticks. You *can* mock that.
> Paul.
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer

Kevin Clark

More information about the mocha-developer mailing list