Sha256: bd02bef3393b8856559edb24c1379687bffa13e4dc0ac894b6415bb51f6ddc7a

Contents?: true

Size: 738 Bytes

Versions: 6

Compression:

Stored size: 738 Bytes

Contents

require 'mechanize/test_case'

class TestMechanizeDownload < Mechanize::TestCase

  def setup
    super

    @parser = Mechanize::Download
  end

  def test_save_string_io
    uri = URI.parse 'http://example/foo.html'
    body_io = StringIO.new '0123456789'

    download = @parser.new uri, nil, body_io

    in_tmpdir do
      download.save

      assert File.exist? 'foo.html'
    end
  end

  def test_save_tempfile
    uri = URI.parse 'http://example/foo.html'
    Tempfile.new __name__ do |body_io|
      body_io.write '0123456789'

      body_io.flush
      body_io.rewind

      download = @parser.new uri, nil, body_io

      in_tmpdir do
        download.save

        assert File.exist? 'foo.html'
      end
    end
  end

end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
domo-0.0.5 vendor/bundle/ruby/1.9.1/gems/mechanize-2.1/test/test_mechanize_download.rb
diamond-mechanize-2.4 test/test_mechanize_download.rb
diamond-mechanize-2.3 test/test_mechanize_download.rb
diamond-mechanize-2.1 test/test_mechanize_download.rb
mechanize-2.1 test/test_mechanize_download.rb
mechanize-2.1.pre.1 test/test_mechanize_download.rb