[rspec-users] Stubbing calls to the command line
mailing_lists at railsnewbie.com
Fri Aug 15 01:43:28 EDT 2008
On Aug 14, 2008, at 11:58 PM, Andy Croll wrote:
> Scott Taylor wrote:
>> Use Kernel.stub!(:`, "wget..."), and use Kernel.send(:`, "wget")
>> instead of literal backticks.
Oops. Meant Kernel.stub!(:`).with("wget..").and_return "some return
> Interestingly this doesn't quite work, but I used the principle.
> The Kernel module is mixed into Object so when you use
> ` you can intercept the call on the object itself.
> So I was able to:
> @my_obj.stub!(:`) ...in the before block
> @my_obj.should_receive(:`, "wget...") ...in the test
> and use the short form:
> `wget... ` ...in the actual method.
> Thanks for your help chaps.
> Posted via http://www.ruby-forum.com/.
> rspec-users mailing list
> rspec-users at rubyforge.org
Yeah - the top level should work, too:
main = self
The downside is that you would need to pass around around your top
level instance of object (what I've been calling "main" here).
More information about the rspec-users