[mocha-developer] Mocking system/`
jpywtora at calpoly.edu
Tue Jun 12 13:00:57 EDT 2007
irb(main):005:0> module Kernel
irb(main):006:1> def `(*args)
irb(main):007:2> raise "nope, not gonna do it"
RuntimeError: nope, not gonna do it
from (irb):7:in ``'
That gives me hope, any ideas?
Kevin Clark wrote:
> 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
>> A more verbose but more flexible alternative might be to use popen or
>> open3 in your code instead of backticks. You *can* mock that.
>> mocha-developer mailing list
>> mocha-developer at rubyforge.org
More information about the mocha-developer