blather 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +3 -0
- data/.travis.yml +1 -8
- data/CHANGELOG.md +230 -0
- data/Guardfile +4 -4
- data/README.md +2 -8
- data/Rakefile +14 -27
- data/blather.gemspec +8 -18
- data/lib/blather.rb +1 -0
- data/lib/blather/client/client.rb +8 -0
- data/lib/blather/roster.rb +7 -0
- data/lib/blather/stanza/iq/roster.rb +1 -1
- data/lib/blather/stanza/message/muc_user.rb +2 -0
- data/lib/blather/stanza/muc/muc_user_base.rb +4 -3
- data/lib/blather/stanza/presence.rb +12 -14
- data/lib/blather/stanza/presence/c.rb +58 -62
- data/lib/blather/stanza/presence/muc.rb +14 -10
- data/lib/blather/stanza/presence/muc_user.rb +47 -36
- data/lib/blather/stanza/presence/status.rb +106 -101
- data/lib/blather/stanza/presence/subscription.rb +59 -60
- data/lib/blather/stream.rb +1 -3
- data/lib/blather/stream/features/resource.rb +0 -1
- data/lib/blather/version.rb +1 -2
- data/lib/blather/xmpp_node.rb +24 -3
- data/spec/blather/client/client_spec.rb +64 -64
- data/spec/blather/client/dsl/pubsub_spec.rb +127 -127
- data/spec/blather/client/dsl_spec.rb +11 -11
- data/spec/blather/errors/sasl_error_spec.rb +3 -3
- data/spec/blather/errors/stanza_error_spec.rb +26 -26
- data/spec/blather/errors/stream_error_spec.rb +22 -22
- data/spec/blather/errors_spec.rb +7 -7
- data/spec/blather/file_transfer_spec.rb +16 -18
- data/spec/blather/jid_spec.rb +29 -29
- data/spec/blather/roster_item_spec.rb +18 -18
- data/spec/blather/roster_spec.rb +18 -18
- data/spec/blather/stanza/discos/disco_info_spec.rb +56 -57
- data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
- data/spec/blather/stanza/iq/command_spec.rb +57 -57
- data/spec/blather/stanza/iq/ibb_spec.rb +27 -39
- data/spec/blather/stanza/iq/ping_spec.rb +13 -9
- data/spec/blather/stanza/iq/query_spec.rb +16 -16
- data/spec/blather/stanza/iq/roster_spec.rb +29 -30
- data/spec/blather/stanza/iq/s5b_spec.rb +10 -13
- data/spec/blather/stanza/iq/si_spec.rb +20 -23
- data/spec/blather/stanza/iq/vcard_spec.rb +22 -25
- data/spec/blather/stanza/iq_spec.rb +12 -12
- data/spec/blather/stanza/message/muc_user_spec.rb +36 -36
- data/spec/blather/stanza/message_spec.rb +56 -56
- data/spec/blather/stanza/presence/c_spec.rb +17 -7
- data/spec/blather/stanza/presence/muc_spec.rb +8 -8
- data/spec/blather/stanza/presence/muc_user_spec.rb +23 -23
- data/spec/blather/stanza/presence/status_spec.rb +42 -30
- data/spec/blather/stanza/presence/subscription_spec.rb +22 -23
- data/spec/blather/stanza/presence_spec.rb +72 -34
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +12 -12
- data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
- data/spec/blather/stanza/pubsub/event_spec.rb +31 -31
- data/spec/blather/stanza/pubsub/items_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/retract_spec.rb +20 -20
- data/spec/blather/stanza/pubsub/subscribe_spec.rb +17 -17
- data/spec/blather/stanza/pubsub/subscription_spec.rb +28 -28
- data/spec/blather/stanza/pubsub/subscriptions_spec.rb +11 -11
- data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +22 -22
- data/spec/blather/stanza/pubsub_owner/delete_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner/purge_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner_spec.rb +6 -6
- data/spec/blather/stanza/pubsub_spec.rb +16 -16
- data/spec/blather/stanza/x_spec.rb +53 -53
- data/spec/blather/stanza_spec.rb +39 -39
- data/spec/blather/stream/client_spec.rb +133 -133
- data/spec/blather/stream/component_spec.rb +7 -7
- data/spec/blather/stream/parser_spec.rb +24 -24
- data/spec/blather/stream/ssl_spec.rb +7 -7
- data/spec/blather/xmpp_node_spec.rb +17 -7
- data/spec/blather_spec.rb +4 -4
- data/spec/spec_helper.rb +6 -54
- metadata +53 -68
- data/CHANGELOG +0 -220
@@ -2,44 +2,44 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blather::Stanza::Iq do
|
4
4
|
it 'registers itself' do
|
5
|
-
Blather::XMPPNode.class_from_registration(:iq, nil).
|
5
|
+
Blather::XMPPNode.class_from_registration(:iq, nil).should == Blather::Stanza::Iq
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'must be importable' do
|
9
|
-
|
10
|
-
Blather::XMPPNode.
|
9
|
+
string = "<iq from='juliet@example.com/balcony' type='set' id='roster_4'></iq>"
|
10
|
+
Blather::XMPPNode.parse(string).should be_instance_of Blather::Stanza::Iq
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'creates a new Iq stanza defaulted as a get' do
|
14
|
-
Blather::Stanza::Iq.new.type.
|
14
|
+
Blather::Stanza::Iq.new.type.should == :get
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'sets the id when created' do
|
18
|
-
Blather::Stanza::Iq.new.id.
|
18
|
+
Blather::Stanza::Iq.new.id.should_not be_nil
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'creates a new Stanza::Iq object on import' do
|
22
|
-
Blather::Stanza::Iq.import(Blather::XMPPNode.new('iq')).
|
22
|
+
Blather::Stanza::Iq.import(Blather::XMPPNode.new('iq')).should be_kind_of Blather::Stanza::Iq
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'creates a proper object based on its children' do
|
26
26
|
n = Blather::XMPPNode.new('iq')
|
27
27
|
n << Blather::XMPPNode.new('query', n.document)
|
28
|
-
Blather::Stanza::Iq.import(n).
|
28
|
+
Blather::Stanza::Iq.import(n).should be_kind_of Blather::Stanza::Iq::Query
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'ensures type is one of Stanza::Iq::VALID_TYPES' do
|
32
|
-
lambda { Blather::Stanza::Iq.new :invalid_type_name }.
|
32
|
+
lambda { Blather::Stanza::Iq.new :invalid_type_name }.should raise_error(Blather::ArgumentError)
|
33
33
|
|
34
34
|
Blather::Stanza::Iq::VALID_TYPES.each do |valid_type|
|
35
35
|
n = Blather::Stanza::Iq.new valid_type
|
36
|
-
n.type.
|
36
|
+
n.type.should == valid_type
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
Blather::Stanza::Iq::VALID_TYPES.each do |valid_type|
|
41
41
|
it "provides a helper (#{valid_type}?) for type #{valid_type}" do
|
42
|
-
Blather::Stanza::Iq.new.
|
42
|
+
Blather::Stanza::Iq.new.should respond_to :"#{valid_type}?"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -48,7 +48,7 @@ describe Blather::Stanza::Iq do
|
|
48
48
|
iq.from = 'them@example.com'
|
49
49
|
iq << Blather::XMPPNode.new('query', iq.document)
|
50
50
|
r = iq.reply
|
51
|
-
r.children.empty?.
|
51
|
+
r.children.empty?.should == true
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'does not remove the body when replying if we ask to keep it' do
|
@@ -56,6 +56,6 @@ describe Blather::Stanza::Iq do
|
|
56
56
|
iq.from = 'them@example.com'
|
57
57
|
iq << Blather::XMPPNode.new('query', iq.document)
|
58
58
|
r = iq.reply :remove_children => false
|
59
|
-
r.children.empty?.
|
59
|
+
r.children.empty?.should == false
|
60
60
|
end
|
61
61
|
end
|
@@ -38,115 +38,115 @@ end
|
|
38
38
|
describe 'Blather::Stanza::Message::MUCUser' do
|
39
39
|
it 'ensures a form node is present on create' do
|
40
40
|
c = Blather::Stanza::Message::MUCUser.new
|
41
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).
|
41
|
+
c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).should_not be_empty
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'ensures a form node exists when calling #muc' do
|
45
45
|
c = Blather::Stanza::Message::MUCUser.new
|
46
46
|
c.remove_children :x
|
47
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).
|
47
|
+
c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).should be_empty
|
48
48
|
|
49
|
-
c.muc_user.
|
50
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).
|
49
|
+
c.muc_user.should_not be_nil
|
50
|
+
c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).should_not be_empty
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'ensures the message type is :normal' do
|
54
54
|
m = Blather::Stanza::Message::MUCUser.new
|
55
|
-
m.normal?.
|
55
|
+
m.normal?.should == true
|
56
56
|
end
|
57
57
|
|
58
58
|
it "must be able to set the password" do
|
59
59
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
60
|
-
muc_user.password.
|
60
|
+
muc_user.password.should == nil
|
61
61
|
muc_user.password = 'barbaz'
|
62
|
-
muc_user.password.
|
62
|
+
muc_user.password.should == 'barbaz'
|
63
63
|
muc_user.password = 'hello_world'
|
64
|
-
muc_user.password.
|
64
|
+
muc_user.password.should == 'hello_world'
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should not be an #invite?" do
|
68
68
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
69
|
-
muc_user.invite?.
|
69
|
+
muc_user.invite?.should == false
|
70
70
|
end
|
71
71
|
|
72
72
|
describe "with an invite element" do
|
73
73
|
it "should be an #invite?" do
|
74
|
-
muc_user = Blather::XMPPNode.
|
75
|
-
muc_user.invite?.
|
74
|
+
muc_user = Blather::XMPPNode.parse(muc_invite_xml)
|
75
|
+
muc_user.invite?.should == true
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should know the invite attributes properly" do
|
79
|
-
muc_user = Blather::XMPPNode.
|
80
|
-
muc_user.
|
79
|
+
muc_user = Blather::XMPPNode.parse(muc_invite_xml)
|
80
|
+
muc_user.should be_instance_of Blather::Stanza::Message::MUCUser
|
81
81
|
invite = muc_user.invite
|
82
|
-
invite.to.
|
83
|
-
invite.from.
|
84
|
-
invite.reason.
|
85
|
-
muc_user.password.
|
82
|
+
invite.to.should == 'hecate@shakespeare.lit'
|
83
|
+
invite.from.should == 'crone1@shakespeare.lit/desktop'
|
84
|
+
invite.reason.should == 'Hey Hecate, this is the place for all good witches!'
|
85
|
+
muc_user.password.should == 'foobar'
|
86
86
|
end
|
87
87
|
|
88
88
|
it "must be able to set the to jid" do
|
89
89
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
90
90
|
invite = muc_user.invite
|
91
|
-
invite.to.
|
91
|
+
invite.to.should == nil
|
92
92
|
invite.to = 'foo@bar.com'
|
93
|
-
invite.to.
|
93
|
+
invite.to.should == 'foo@bar.com'
|
94
94
|
end
|
95
95
|
|
96
96
|
it "must be able to set the from jid" do
|
97
97
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
98
98
|
invite = muc_user.invite
|
99
|
-
invite.from.
|
99
|
+
invite.from.should == nil
|
100
100
|
invite.from = 'foo@bar.com'
|
101
|
-
invite.from.
|
101
|
+
invite.from.should == 'foo@bar.com'
|
102
102
|
end
|
103
103
|
|
104
104
|
it "must be able to set the reason" do
|
105
105
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
106
106
|
invite = muc_user.invite
|
107
|
-
invite.reason.
|
107
|
+
invite.reason.should == ''
|
108
108
|
invite.reason = 'Please join'
|
109
|
-
invite.reason.
|
109
|
+
invite.reason.should == 'Please join'
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
describe "with a decline element" do
|
114
114
|
it "should be an #invite_decline?" do
|
115
|
-
muc_user = Blather::XMPPNode.
|
116
|
-
muc_user.
|
117
|
-
muc_user.invite_decline?.
|
115
|
+
muc_user = Blather::XMPPNode.parse(muc_decline_xml)
|
116
|
+
muc_user.should be_instance_of Blather::Stanza::Message::MUCUser
|
117
|
+
muc_user.invite_decline?.should == true
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should know the decline attributes properly" do
|
121
|
-
muc_user = Blather::XMPPNode.
|
121
|
+
muc_user = Blather::XMPPNode.parse(muc_decline_xml)
|
122
122
|
decline = muc_user.decline
|
123
|
-
decline.to.
|
124
|
-
decline.from.
|
125
|
-
decline.reason.
|
123
|
+
decline.to.should == 'crone1@shakespeare.lit'
|
124
|
+
decline.from.should == 'hecate@shakespeare.lit'
|
125
|
+
decline.reason.should == "Sorry, I'm too busy right now."
|
126
126
|
end
|
127
127
|
|
128
128
|
it "must be able to set the to jid" do
|
129
129
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
130
130
|
decline = muc_user.decline
|
131
|
-
decline.to.
|
131
|
+
decline.to.should == nil
|
132
132
|
decline.to = 'foo@bar.com'
|
133
|
-
decline.to.
|
133
|
+
decline.to.should == 'foo@bar.com'
|
134
134
|
end
|
135
135
|
|
136
136
|
it "must be able to set the from jid" do
|
137
137
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
138
138
|
decline = muc_user.decline
|
139
|
-
decline.from.
|
139
|
+
decline.from.should == nil
|
140
140
|
decline.from = 'foo@bar.com'
|
141
|
-
decline.from.
|
141
|
+
decline.from.should == 'foo@bar.com'
|
142
142
|
end
|
143
143
|
|
144
144
|
it "must be able to set the reason" do
|
145
145
|
muc_user = Blather::Stanza::Message::MUCUser.new
|
146
146
|
decline = muc_user.decline
|
147
|
-
decline.reason.
|
147
|
+
decline.reason.should == ''
|
148
148
|
decline.reason = 'Please join'
|
149
|
-
decline.reason.
|
149
|
+
decline.reason.should == 'Please join'
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
@@ -70,67 +70,67 @@ end
|
|
70
70
|
|
71
71
|
describe Blather::Stanza::Message do
|
72
72
|
it 'registers itself' do
|
73
|
-
Blather::XMPPNode.class_from_registration(:message, nil).
|
73
|
+
Blather::XMPPNode.class_from_registration(:message, nil).should == Blather::Stanza::Message
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'must be importable' do
|
77
|
-
Blather::XMPPNode.
|
78
|
-
Blather::XMPPNode.
|
77
|
+
Blather::XMPPNode.parse(message_xml).should be_instance_of Blather::Stanza::Message
|
78
|
+
Blather::XMPPNode.parse(ichat_message_xml).should be_instance_of Blather::Stanza::Message
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'provides "attr_accessor" for body' do
|
82
82
|
s = Blather::Stanza::Message.new
|
83
|
-
s.body.
|
84
|
-
s.find('body').
|
83
|
+
s.body.should be_nil
|
84
|
+
s.find('body').should be_empty
|
85
85
|
|
86
86
|
s.body = 'test message'
|
87
|
-
s.body.
|
88
|
-
s.find('body').
|
87
|
+
s.body.should_not be_nil
|
88
|
+
s.find('body').should_not be_empty
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'provides "attr_accessor" for subject' do
|
92
92
|
s = Blather::Stanza::Message.new
|
93
|
-
s.subject.
|
94
|
-
s.find('subject').
|
93
|
+
s.subject.should be_nil
|
94
|
+
s.find('subject').should be_empty
|
95
95
|
|
96
96
|
s.subject = 'test subject'
|
97
|
-
s.subject.
|
98
|
-
s.find('subject').
|
97
|
+
s.subject.should_not be_nil
|
98
|
+
s.find('subject').should_not be_empty
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'provides "attr_accessor" for thread' do
|
102
102
|
s = Blather::Stanza::Message.new
|
103
|
-
s.thread.
|
104
|
-
s.find('thread').
|
103
|
+
s.thread.should be_nil
|
104
|
+
s.find('thread').should be_empty
|
105
105
|
|
106
106
|
s.thread = 1234
|
107
|
-
s.thread.
|
108
|
-
s.find('thread').
|
107
|
+
s.thread.should_not be_nil
|
108
|
+
s.find('thread').should_not be_empty
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'can set a parent attribute for thread' do
|
112
112
|
s = Blather::Stanza::Message.new
|
113
|
-
s.thread.
|
114
|
-
s.find('thread').
|
113
|
+
s.thread.should be_nil
|
114
|
+
s.find('thread').should be_empty
|
115
115
|
|
116
116
|
s.thread = {4321 => 1234}
|
117
|
-
s.thread.
|
118
|
-
s.parent_thread.
|
119
|
-
s.find('thread[@parent="4321"]').
|
117
|
+
s.thread.should == '1234'
|
118
|
+
s.parent_thread.should == '4321'
|
119
|
+
s.find('thread[@parent="4321"]').should_not be_empty
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'ensures type is one of Blather::Stanza::Message::VALID_TYPES' do
|
123
|
-
lambda { Blather::Stanza::Message.new nil, nil, :invalid_type_name }.
|
123
|
+
lambda { Blather::Stanza::Message.new nil, nil, :invalid_type_name }.should raise_error(Blather::ArgumentError)
|
124
124
|
|
125
125
|
Blather::Stanza::Message::VALID_TYPES.each do |valid_type|
|
126
126
|
msg = Blather::Stanza::Message.new nil, nil, valid_type
|
127
|
-
msg.type.
|
127
|
+
msg.type.should == valid_type
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
131
|
Blather::Stanza::Message::VALID_TYPES.each do |valid_type|
|
132
132
|
it "provides a helper (#{valid_type}?) for type #{valid_type}" do
|
133
|
-
Blather::Stanza::Message.new.
|
133
|
+
Blather::Stanza::Message.new.should respond_to :"#{valid_type}?"
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -140,10 +140,10 @@ describe Blather::Stanza::Message do
|
|
140
140
|
{:html_ns => Blather::Stanza::Message::HTML_NS}
|
141
141
|
]
|
142
142
|
msg = Blather::Stanza::Message.new
|
143
|
-
msg.find_first(*search_args).
|
143
|
+
msg.find_first(*search_args).should be_nil
|
144
144
|
|
145
145
|
msg.xhtml_node
|
146
|
-
msg.find_first(*search_args).
|
146
|
+
msg.find_first(*search_args).should_not be_nil
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'ensures a body node exists when asked for xhtml_node' do
|
@@ -153,10 +153,10 @@ describe Blather::Stanza::Message do
|
|
153
153
|
:body_ns => Blather::Stanza::Message::HTML_BODY_NS}
|
154
154
|
]
|
155
155
|
msg = Blather::Stanza::Message.new
|
156
|
-
msg.find_first(*search_args).
|
156
|
+
msg.find_first(*search_args).should be_nil
|
157
157
|
|
158
158
|
msg.xhtml_node
|
159
|
-
msg.find_first(*search_args).
|
159
|
+
msg.find_first(*search_args).should_not be_nil
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'returns an existing node when asked for xhtml_node' do
|
@@ -167,46 +167,46 @@ describe Blather::Stanza::Message do
|
|
167
167
|
b.namespace = Blather::Stanza::Message::HTML_BODY_NS
|
168
168
|
h << b
|
169
169
|
|
170
|
-
msg.xhtml_node.
|
170
|
+
msg.xhtml_node.should ==(b)
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'has an xhtml setter' do
|
174
174
|
msg = Blather::Stanza::Message.new
|
175
175
|
xhtml = "<some>xhtml</some>"
|
176
176
|
msg.xhtml = xhtml
|
177
|
-
msg.xhtml_node.inner_html.strip.
|
177
|
+
msg.xhtml_node.inner_html.strip.should ==(xhtml)
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'sets valid xhtml even if the input is not valid' do
|
181
181
|
msg = Blather::Stanza::Message.new
|
182
182
|
xhtml = "<some>xhtml"
|
183
183
|
msg.xhtml = xhtml
|
184
|
-
msg.xhtml_node.inner_html.strip.
|
184
|
+
msg.xhtml_node.inner_html.strip.should ==("<some>xhtml</some>")
|
185
185
|
end
|
186
186
|
|
187
187
|
it 'sets xhtml with more than one root node' do
|
188
188
|
msg = Blather::Stanza::Message.new
|
189
189
|
xhtml = "<i>xhtml</i> more xhtml"
|
190
190
|
msg.xhtml = xhtml
|
191
|
-
msg.xhtml_node.inner_html.strip.
|
191
|
+
msg.xhtml_node.inner_html.strip.should ==("<i>xhtml</i> more xhtml")
|
192
192
|
end
|
193
193
|
|
194
194
|
it 'has an xhtml getter' do
|
195
195
|
msg = Blather::Stanza::Message.new
|
196
196
|
xhtml = "<some>xhtml</some>"
|
197
197
|
msg.xhtml = xhtml
|
198
|
-
msg.xhtml.
|
198
|
+
msg.xhtml.should ==(xhtml)
|
199
199
|
end
|
200
200
|
|
201
201
|
it 'finds xhtml body when html wrapper has wrong namespace' do
|
202
|
-
msg = Blather::XMPPNode.
|
203
|
-
msg.xhtml.
|
202
|
+
msg = Blather::XMPPNode.parse(ichat_message_xml)
|
203
|
+
msg.xhtml.should == "<span style=\"font-family: 'Arial';font-size: 12px;color: #262626;\">Hello</span>\n <img alt=\"f5ad3a04d218d7160fa02415e02d41b3.jpg\" src=\"message-attachments:1\" width=\"30\" height=\"30\"></img>"
|
204
204
|
end
|
205
205
|
|
206
206
|
it 'has a chat state setter' do
|
207
207
|
msg = Blather::Stanza::Message.new
|
208
208
|
msg.chat_state = :composing
|
209
|
-
msg.xpath('ns:composing', :ns => Blather::Stanza::Message::CHAT_STATE_NS).
|
209
|
+
msg.xpath('ns:composing', :ns => Blather::Stanza::Message::CHAT_STATE_NS).should_not be_empty
|
210
210
|
end
|
211
211
|
|
212
212
|
it 'will only add one chat state at a time' do
|
@@ -214,69 +214,69 @@ describe Blather::Stanza::Message do
|
|
214
214
|
msg.chat_state = :composing
|
215
215
|
msg.chat_state = :paused
|
216
216
|
|
217
|
-
msg.xpath('ns:*', :ns => Blather::Stanza::Message::CHAT_STATE_NS).size.
|
217
|
+
msg.xpath('ns:*', :ns => Blather::Stanza::Message::CHAT_STATE_NS).size.should ==(1)
|
218
218
|
end
|
219
219
|
|
220
220
|
it 'ensures chat state setter accepts strings' do
|
221
221
|
msg = Blather::Stanza::Message.new
|
222
222
|
msg.chat_state = "gone"
|
223
|
-
msg.xpath('ns:gone', :ns => Blather::Stanza::Message::CHAT_STATE_NS).
|
223
|
+
msg.xpath('ns:gone', :ns => Blather::Stanza::Message::CHAT_STATE_NS).should_not be_empty
|
224
224
|
end
|
225
225
|
|
226
226
|
it 'ensures chat state is one of Blather::Stanza::Message::VALID_CHAT_STATES' do
|
227
227
|
lambda do
|
228
228
|
msg = Blather::Stanza::Message.new
|
229
229
|
msg.chat_state = :invalid_chat_state
|
230
|
-
end.
|
230
|
+
end.should raise_error(Blather::ArgumentError)
|
231
231
|
|
232
232
|
Blather::Stanza::Message::VALID_CHAT_STATES.each do |valid_chat_state|
|
233
233
|
msg = Blather::Stanza::Message.new
|
234
234
|
msg.chat_state = valid_chat_state
|
235
|
-
msg.chat_state.
|
235
|
+
msg.chat_state.should == valid_chat_state
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
239
239
|
it 'has a chat state getter' do
|
240
240
|
msg = Blather::Stanza::Message.new
|
241
241
|
msg.chat_state = :paused
|
242
|
-
msg.chat_state.
|
242
|
+
msg.chat_state.should ==(:paused)
|
243
243
|
end
|
244
244
|
|
245
245
|
it 'imports correct chat state' do
|
246
|
-
Blather::XMPPNode.
|
246
|
+
Blather::XMPPNode.parse(message_xml).chat_state.should == :paused
|
247
247
|
end
|
248
248
|
|
249
249
|
it 'makes a form child available' do
|
250
|
-
n = Blather::XMPPNode.
|
251
|
-
n.form.fields.size.
|
252
|
-
n.form.fields.map { |f| f.class }.uniq.
|
253
|
-
n.form.
|
250
|
+
n = Blather::XMPPNode.parse(message_xml)
|
251
|
+
n.form.fields.size.should == 1
|
252
|
+
n.form.fields.map { |f| f.class }.uniq.should == [Blather::Stanza::X::Field]
|
253
|
+
n.form.should be_instance_of Blather::Stanza::X
|
254
254
|
|
255
255
|
r = Blather::Stanza::Message.new
|
256
256
|
r.form.type = :form
|
257
|
-
r.form.type.
|
257
|
+
r.form.type.should == :form
|
258
258
|
end
|
259
259
|
|
260
260
|
it 'ensures the form child is a direct child' do
|
261
261
|
r = Blather::Stanza::Message.new
|
262
262
|
r.form
|
263
|
-
r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).
|
263
|
+
r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).should_not be_empty
|
264
264
|
end
|
265
265
|
|
266
266
|
it 'is not delayed' do
|
267
|
-
n = Blather::XMPPNode.
|
268
|
-
n.delay.
|
269
|
-
n.delayed?.
|
267
|
+
n = Blather::XMPPNode.parse(message_xml)
|
268
|
+
n.delay.should == nil
|
269
|
+
n.delayed?.should == false
|
270
270
|
end
|
271
271
|
|
272
272
|
describe "with a delay" do
|
273
273
|
it "is delayed" do
|
274
|
-
n = Blather::XMPPNode.
|
275
|
-
n.delayed?.
|
276
|
-
n.delay.
|
277
|
-
n.delay.from.
|
278
|
-
n.delay.stamp.
|
279
|
-
n.delay.description.
|
274
|
+
n = Blather::XMPPNode.parse(delayed_message_xml)
|
275
|
+
n.delayed?.should == true
|
276
|
+
n.delay.should be_instance_of Blather::Stanza::Message::Delay
|
277
|
+
n.delay.from.should == 'coven@chat.shakespeare.lit'
|
278
|
+
n.delay.stamp.should == Time.utc(2002, 10, 13, 23, 58, 37, 0)
|
279
|
+
n.delay.description.should == "Too slow"
|
280
280
|
end
|
281
281
|
end
|
282
282
|
end
|