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
value".
Interestingly this doesn't quite work, but I used the principle.
The Kernel module is mixed into Object so when you use
`shellcommand...
` you can intercept the call on the object itself.
So I was able to:
@my_obj.stub!(:`) ...in the before block
and
@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@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
Yeah - the top level should work, too:
main = self
main.should_receive(:`).with("wget...")
`wget...`
The downside is that you would need to pass around around your top
level instance of object (what I've been calling "main" here).
Scott
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users