File: test_mechanize_file.rb

package info (click to toggle)
libwww-mechanize-ruby 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 956 kB
  • ctags: 883
  • sloc: ruby: 6,621; makefile: 4
file content (47 lines) | stat: -rw-r--r-- 1,603 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require "helper"

class MechanizeFileTest < Test::Unit::TestCase
  def test_content_disposition
    file = 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 = 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 = 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 = Mechanize::File.new(
                                    URI.parse('http://localhost/foo'),
                                    {}
           )
    assert_equal('foo.html', file.filename)

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

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

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