Class: IqVcardTest
Instance Method Summary
collapse
#assert_array_equal, expect, #run
Instance Method Details
#test_create ⇒ Object
11
12
13
14
|
# File 'lib/gems/xmpp4r-0.4/test/vcard/tc_iqvcard.rb', line 11
def test_create
v = Vcard::IqVcard.new
assert_equal([], v.fields)
end
|
#test_create_with_fields ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/gems/xmpp4r-0.4/test/vcard/tc_iqvcard.rb', line 16
def test_create_with_fields
v = Vcard::IqVcard.new({'FN' => 'B C', 'NICKNAME' => 'D'})
assert_equal(['FN', 'NICKNAME'], v.fields.sort)
assert_equal('B C', v['FN'])
assert_equal('D', v['NICKNAME'])
assert_equal(nil, v['x'])
end
|
#test_deep ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/gems/xmpp4r-0.4/test/vcard/tc_iqvcard.rb', line 39
def test_deep
v = Vcard::IqVcard.new({
'FN' => 'John D. Random',
'PHOTO/TYPE' => 'image/png',
'PHOTO/BINVAL' => '===='})
assert_equal(['FN', 'PHOTO/BINVAL', 'PHOTO/TYPE'], v.fields.sort)
assert_equal('John D. Random', v['FN'])
assert_equal('image/png', v['PHOTO/TYPE'])
assert_equal('====', v['PHOTO/BINVAL'])
assert_equal(nil, v['PHOTO'])
assert_equal(nil, v['NICKNAME'])
end
|
#test_fields ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/gems/xmpp4r-0.4/test/vcard/tc_iqvcard.rb', line 24
def test_fields
v = Vcard::IqVcard.new
f = ['a', 'b', 'c', 'd', 'e']
f.each { |s|
v[s.downcase] = s.upcase
}
assert_equal(f, v.fields.sort)
f.each { |s|
assert_equal(s.upcase, v[s.downcase])
assert_equal(nil, v[s.upcase])
}
end
|
#test_photo_binval ⇒ Object
53
54
55
56
|
# File 'lib/gems/xmpp4r-0.4/test/vcard/tc_iqvcard.rb', line 53
def test_photo_binval
v = Vcard::IqVcard.new({'PHOTO/BINVAL'=>"SGVsbG8gd29ybGQ=\n"})
assert_equal('Hello world', v.photo_binval)
end
|
#test_photo_binval_nil ⇒ Object
58
59
60
61
|
# File 'lib/gems/xmpp4r-0.4/test/vcard/tc_iqvcard.rb', line 58
def test_photo_binval_nil
v = Vcard::IqVcard.new({})
assert_nil(v.photo_binval)
end
|