[rspec-users] Stubbing calls to the command line

Andy Croll lists at ruby-forum.com
Thu Aug 14 03:42:45 EDT 2008

I'm using a call to wget to download a large datafile (multiple
megabytes) having assumed this will be quicker than using open-uri.

How can I spec the behaviour? Ideally I'd also like to not be hitting
the internet every time I test!

in my_object_spec.rb

  describe ".get_data" do
    before(:each) do
      @my_obj = MyObject.create(@valid_attributes)
    it "should download the file" do
      # behaviour goes here

in my_object.rb:

  def get_data
      `wget --output-document=#{self.filename} #{self.file_uri}`

I'll be massively grateful for any help anyone can give me.
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list