[mocha-developer] Mocking system/`

Paul Battley pbattley at gmail.com
Tue Jun 12 05:33:19 EDT 2007

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.


More information about the mocha-developer mailing list