Sha256: f35a94b5b73a770f3ba6f4199f2a14da87f6709d32f233610988588b5de21649

Contents?: true

Size: 1.65 KB

Versions: 15

Compression:

Stored size: 1.65 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "helper"))

class MechanizeFileTest < Test::Unit::TestCase
  def test_content_disposition
    file = WWW::Mechanize::File.new(
                                    URI.parse('http://localhost/foo'),
           { 'content-disposition' => 'attachment; filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"', }
           )
    assert_equal('genome.jpeg', file.filename)

    file = WWW::Mechanize::File.new(
                                    URI.parse('http://localhost/foo'),
           { 'content-disposition' => 'filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"', }
           )
    assert_equal('genome.jpeg', file.filename)

    file = WWW::Mechanize::File.new(
                                    URI.parse('http://localhost/foo'),
           { 'content-disposition' => 'filename=genome.jpeg', }
           )
    assert_equal('genome.jpeg', file.filename)
  end

  def test_from_uri
    file = WWW::Mechanize::File.new(
                                    URI.parse('http://localhost/foo'),
                                    {}
           )
    assert_equal('foo.html', file.filename)

    file = WWW::Mechanize::File.new(
                                    URI.parse('http://localhost/foo.jpg'),
                                    {}
           )
    assert_equal('foo.jpg', file.filename)

    file = WWW::Mechanize::File.new(
                                    URI.parse('http://localhost/foo.jpg')
           )
    assert_equal('foo.jpg', file.filename)
  end

  def test_no_uri
    file = WWW::Mechanize::File.new()
    assert_equal('index.html', file.filename)
  end
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
eric-mechanize-0.9.3.20090623142847 test/test_mechanize_file.rb
knu-mechanize-0.9.3.20090623142847 test/test_mechanize_file.rb
tenderlove-mechanize-0.9.3.20090617085936 test/test_mechanize_file.rb
tenderlove-mechanize-0.9.3.20090623142847 test/test_mechanize_file.rb
mechanize-ntlm-0.9.1 test/test_mechanize_file.rb
mechanize-0.8.0 test/test_mechanize_file.rb
mechanize-0.8.3 test/test_mechanize_file.rb
mechanize-0.8.2 test/test_mechanize_file.rb
mechanize-0.8.1 test/test_mechanize_file.rb
mechanize-0.8.4 test/test_mechanize_file.rb
mechanize-0.9.1 test/test_mechanize_file.rb
mechanize-0.9.2 test/test_mechanize_file.rb
mechanize-0.9.3 test/test_mechanize_file.rb
mechanize-0.8.5 test/test_mechanize_file.rb
mechanize-0.9.0 test/test_mechanize_file.rb