Class: StreamParserTest
Constant Summary
collapse
- STREAM =
'<stream:stream xmlns:stream="http://etherx.jabber.org/streams">'
Instance Method Summary
collapse
#assert_array_equal, expect, #run
Instance Method Details
#parse_simple_helper(fixture) {|parse_with_rexml(fixture)| ... } ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 35
def parse_simple_helper(fixture)
parser = StreamParser.new(STREAM + fixture, @listener)
parser.parse
yield parse_with_rexml(fixture)
end
|
#parse_with_rexml(fixture) ⇒ Object
43
44
45
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 43
def parse_with_rexml(fixture)
REXML::Document.new(fixture).root
end
|
27
28
29
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 27
def setup
@listener = MockListener.new
end
|
31
32
33
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 31
def teardown
@listener = nil
end
|
#test_complex_composite_cdata_text ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 79
def test_complex_composite_cdata_text
parse_simple_helper( "<a><![CDATA[<cdata>]]>text<![CDATA[<cdata>]]>text</a>" ) do |desired|
assert_equal desired.name, @listener.received.name
assert_equal desired.text, @listener.received.text
assert_equal desired.cdatas, @listener.received.cdatas
end
end
|
#test_composite_cdata_text ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 71
def test_composite_cdata_text
parse_simple_helper( "<a><![CDATA[<cdata>]]>text</a>" ) do |desired|
assert_equal desired.name, @listener.received.name
assert_equal desired.text, @listener.received.text
assert_equal desired.cdatas, @listener.received.cdatas
end
end
|
#test_composite_text_cdata ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 63
def test_composite_text_cdata
parse_simple_helper( "<a>text<![CDATA[<cdata>]]></a>" ) do |desired|
assert_equal desired.name, @listener.received.name
assert_equal desired.text, @listener.received.text
assert_equal desired.cdatas, @listener.received.cdatas
end
end
|
#test_entity_escaping1 ⇒ Object
87
88
89
90
91
92
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 87
def test_entity_escaping1
parse_simple_helper( "<a>'&"</a>" ) do |desired|
assert_equal "'&\"", @listener.received.text
assert_equal "<a>'&"</a>", @listener.received.to_s
end
end
|
#test_entity_escaping2 ⇒ Object
94
95
96
97
98
99
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 94
def test_entity_escaping2
parse_simple_helper( "<a>&amp;amp;</a>" ) do |desired|
assert_equal "&amp;", @listener.received.text
assert_equal "<a>&amp;amp;</a>", @listener.received.to_s
end
end
|
#test_simple_cdata ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 55
def test_simple_cdata
parse_simple_helper( "<a><![CDATA[<cdata>]]></a>" ) do |desired|
assert_equal desired.name, @listener.received.name
assert_equal desired.text, @listener.received.text
assert_equal desired.cdatas, @listener.received.cdatas
end
end
|
#test_simple_text ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/gems/xmpp4r-0.4/test/tc_streamparser.rb', line 47
def test_simple_text
parse_simple_helper( "<a>text</a>" ) do |desired|
assert_equal desired.name, @listener.received.name
assert_equal desired.text, @listener.received.text
assert_equal desired.cdatas, @listener.received.cdatas
end
end
|