File: test_mechanize_headers.rb

package info (click to toggle)
ruby-mechanize 2.7.6-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,480 kB
  • sloc: ruby: 11,380; makefile: 5; sh: 4
file content (35 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (6)
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
require 'mechanize/test_case'

class TestMechanizeHeaders < Mechanize::TestCase
  def setup
    super

    @headers = Mechanize::Headers.new
    @headers['content-type'] = 'text/html'
    @headers['Content-encoding'] = 'gzip'
    @headers['SERVER'] = 'Apache/2.2'
  end

  def test_aref
    assert_equal('Apache/2.2', @headers['server'])
    assert_equal('text/html', @headers['Content-Type'])
  end

  def test_key?
    assert_equal(true, @headers.key?('content-Encoding'))
  end

  def test_canonical_each
    all_keys = ['Content-Type', 'Content-Encoding', 'Server']
    keys = all_keys.dup
    @headers.canonical_each { |key, value|
      case keys.delete(key)
      when *all_keys
        # ok
      else
        flunk "unexpected key: #{key}"
      end
    }
    assert_equal([], keys)
  end
end