-
Notifications
You must be signed in to change notification settings - Fork 474
/
test_mechanize_http_auth_realm.rb
56 lines (39 loc) · 1.08 KB
/
test_mechanize_http_auth_realm.rb
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
48
49
50
51
52
53
54
55
# frozen_string_literal: true
require 'mechanize/test_case'
class TestMechanizeHttpAuthRealm < Mechanize::TestCase
def setup
super
@uri = URI 'http://example/'
@AR = Mechanize::HTTP::AuthRealm
@realm = @AR.new 'Digest', @uri, 'r'
end
def test_initialize
assert_equal 'r', @realm.realm
realm = @AR.new 'Digest', @uri, 'R'
refute_equal 'r', realm.realm
realm = @AR.new 'Digest', @uri, 'R'
assert_equal 'R', realm.realm
realm = @AR.new 'Digest', @uri, nil
assert_nil realm.realm
end
def test_equals2
other = @realm.dup
assert_equal @realm, other
other = @AR.new 'Basic', @uri, 'r'
refute_equal @realm, other
other = @AR.new 'Digest', URI('http://other.example/'), 'r'
refute_equal @realm, other
other = @AR.new 'Digest', @uri, 'R'
refute_equal @realm, other
other = @AR.new 'Digest', @uri, 's'
refute_equal @realm, other
end
def test_hash
h = {}
h[@realm] = 1
other = @realm.dup
assert_equal 1, h[other]
other = @AR.new 'Basic', @uri, 'r'
assert_nil h[other]
end
end