blather 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +7 -7
- data/CHANGELOG.md +8 -0
- data/blather.gemspec +6 -6
- data/lib/blather.rb +1 -1
- data/lib/blather/client/client.rb +30 -6
- data/lib/blather/version.rb +1 -1
- data/spec/blather/client/client_spec.rb +73 -68
- data/spec/blather/client/dsl/pubsub_spec.rb +121 -121
- data/spec/blather/client/dsl_spec.rb +9 -9
- 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 +9 -9
- 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 -56
- data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
- data/spec/blather/stanza/iq/command_spec.rb +51 -51
- data/spec/blather/stanza/iq/ibb_spec.rb +15 -15
- data/spec/blather/stanza/iq/ping_spec.rb +8 -8
- data/spec/blather/stanza/iq/query_spec.rb +15 -15
- data/spec/blather/stanza/iq/roster_spec.rb +29 -29
- data/spec/blather/stanza/iq/s5b_spec.rb +7 -7
- data/spec/blather/stanza/iq/si_spec.rb +17 -17
- data/spec/blather/stanza/iq/vcard_spec.rb +19 -19
- data/spec/blather/stanza/iq_spec.rb +11 -11
- data/spec/blather/stanza/message/muc_user_spec.rb +32 -32
- data/spec/blather/stanza/message_spec.rb +53 -54
- data/spec/blather/stanza/presence/c_spec.rb +11 -11
- data/spec/blather/stanza/presence/muc_spec.rb +7 -7
- data/spec/blather/stanza/presence/muc_user_spec.rb +22 -22
- data/spec/blather/stanza/presence/status_spec.rb +33 -33
- data/spec/blather/stanza/presence/subscription_spec.rb +22 -22
- data/spec/blather/stanza/presence_spec.rb +30 -30
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +11 -11
- data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
- data/spec/blather/stanza/pubsub/event_spec.rb +24 -24
- data/spec/blather/stanza/pubsub/items_spec.rb +20 -20
- data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/retract_spec.rb +19 -19
- 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 +13 -13
- 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 +15 -15
- data/spec/blather/stanza/x_spec.rb +53 -53
- data/spec/blather/stanza_spec.rb +39 -39
- data/spec/blather/stream/client_spec.rb +160 -160
- data/spec/blather/stream/component_spec.rb +8 -10
- data/spec/blather/stream/parser_spec.rb +25 -25
- data/spec/blather/stream/ssl_spec.rb +3 -3
- data/spec/blather/xmpp_node_spec.rb +9 -9
- data/spec/blather_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +26 -27
@@ -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
|
+
expect(Blather::XMPPNode.class_from_registration(:iq, nil)).to eq(Blather::Stanza::Iq)
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'must be importable' do
|
9
9
|
string = "<iq from='juliet@example.com/balcony' type='set' id='roster_4'></iq>"
|
10
|
-
Blather::XMPPNode.parse(string).
|
10
|
+
expect(Blather::XMPPNode.parse(string)).to 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
|
+
expect(Blather::Stanza::Iq.new.type).to eq(:get)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'sets the id when created' do
|
18
|
-
Blather::Stanza::Iq.new.id.
|
18
|
+
expect(Blather::Stanza::Iq.new.id).not_to 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
|
+
expect(Blather::Stanza::Iq.import(Blather::XMPPNode.new('iq'))).to 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
|
+
expect(Blather::Stanza::Iq.import(n)).to 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
|
-
|
32
|
+
expect { Blather::Stanza::Iq.new :invalid_type_name }.to 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
|
+
expect(n.type).to eq(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
|
+
expect(Blather::Stanza::Iq.new).to 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
|
+
expect(r.children.empty?).to eq(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
|
+
expect(r.children.empty?).to eq(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
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns)).not_to 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
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns)).to be_empty
|
48
48
|
|
49
|
-
c.muc_user.
|
50
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).
|
49
|
+
expect(c.muc_user).not_to be_nil
|
50
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns)).not_to 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
|
+
expect(m.normal?).to eq(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
|
+
expect(muc_user.password).to eq(nil)
|
61
61
|
muc_user.password = 'barbaz'
|
62
|
-
muc_user.password.
|
62
|
+
expect(muc_user.password).to eq('barbaz')
|
63
63
|
muc_user.password = 'hello_world'
|
64
|
-
muc_user.password.
|
64
|
+
expect(muc_user.password).to eq('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
|
+
expect(muc_user.invite?).to eq(false)
|
70
70
|
end
|
71
71
|
|
72
72
|
describe "with an invite element" do
|
73
73
|
it "should be an #invite?" do
|
74
74
|
muc_user = Blather::XMPPNode.parse(muc_invite_xml)
|
75
|
-
muc_user.invite
|
75
|
+
expect(muc_user.invite?).to eq(true)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should know the invite attributes properly" do
|
79
79
|
muc_user = Blather::XMPPNode.parse(muc_invite_xml)
|
80
|
-
muc_user.
|
80
|
+
expect(muc_user).to 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
|
+
expect(invite.to).to eq('hecate@shakespeare.lit')
|
83
|
+
expect(invite.from).to eq('crone1@shakespeare.lit/desktop')
|
84
|
+
expect(invite.reason).to eq('Hey Hecate, this is the place for all good witches!')
|
85
|
+
expect(muc_user.password).to eq('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
|
+
expect(invite.to).to eq(nil)
|
92
92
|
invite.to = 'foo@bar.com'
|
93
|
-
invite.to.
|
93
|
+
expect(invite.to).to eq('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
|
+
expect(invite.from).to eq(nil)
|
100
100
|
invite.from = 'foo@bar.com'
|
101
|
-
invite.from.
|
101
|
+
expect(invite.from).to eq('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
|
+
expect(invite.reason).to eq('')
|
108
108
|
invite.reason = 'Please join'
|
109
|
-
invite.reason.
|
109
|
+
expect(invite.reason).to eq('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
115
|
muc_user = Blather::XMPPNode.parse(muc_decline_xml)
|
116
|
-
muc_user.
|
117
|
-
muc_user.invite_decline
|
116
|
+
expect(muc_user).to be_instance_of Blather::Stanza::Message::MUCUser
|
117
|
+
expect(muc_user.invite_decline?).to eq(true)
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should know the decline attributes properly" do
|
121
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
|
+
expect(decline.to).to eq('crone1@shakespeare.lit')
|
124
|
+
expect(decline.from).to eq('hecate@shakespeare.lit')
|
125
|
+
expect(decline.reason).to eq("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
|
+
expect(decline.to).to eq(nil)
|
132
132
|
decline.to = 'foo@bar.com'
|
133
|
-
decline.to.
|
133
|
+
expect(decline.to).to eq('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
|
+
expect(decline.from).to eq(nil)
|
140
140
|
decline.from = 'foo@bar.com'
|
141
|
-
decline.from.
|
141
|
+
expect(decline.from).to eq('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
|
+
expect(decline.reason).to eq('')
|
148
148
|
decline.reason = 'Please join'
|
149
|
-
decline.reason.
|
149
|
+
expect(decline.reason).to eq('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
|
+
expect(Blather::XMPPNode.class_from_registration(:message, nil)).to eq(Blather::Stanza::Message)
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'must be importable' do
|
77
|
-
Blather::XMPPNode.parse(message_xml).
|
78
|
-
Blather::XMPPNode.parse(ichat_message_xml).
|
77
|
+
expect(Blather::XMPPNode.parse(message_xml)).to be_instance_of Blather::Stanza::Message
|
78
|
+
expect(Blather::XMPPNode.parse(ichat_message_xml)).to 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
|
+
expect(s.body).to be_nil
|
84
|
+
expect(s.find('body')).to be_empty
|
85
85
|
|
86
86
|
s.body = 'test message'
|
87
|
-
s.body.
|
88
|
-
s.find('body').
|
87
|
+
expect(s.body).not_to be_nil
|
88
|
+
expect(s.find('body')).not_to 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
|
+
expect(s.subject).to be_nil
|
94
|
+
expect(s.find('subject')).to be_empty
|
95
95
|
|
96
96
|
s.subject = 'test subject'
|
97
|
-
s.subject.
|
98
|
-
s.find('subject').
|
97
|
+
expect(s.subject).not_to be_nil
|
98
|
+
expect(s.find('subject')).not_to 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
|
+
expect(s.thread).to be_nil
|
104
|
+
expect(s.find('thread')).to be_empty
|
105
105
|
|
106
106
|
s.thread = 1234
|
107
|
-
s.thread.
|
108
|
-
s.find('thread').
|
107
|
+
expect(s.thread).not_to be_nil
|
108
|
+
expect(s.find('thread')).not_to 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
|
+
expect(s.thread).to be_nil
|
114
|
+
expect(s.find('thread')).to be_empty
|
115
115
|
|
116
116
|
s.thread = {4321 => 1234}
|
117
|
-
s.thread.
|
118
|
-
s.parent_thread.
|
119
|
-
s.find('thread[@parent="4321"]').
|
117
|
+
expect(s.thread).to eq('1234')
|
118
|
+
expect(s.parent_thread).to eq('4321')
|
119
|
+
expect(s.find('thread[@parent="4321"]')).not_to be_empty
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'ensures type is one of Blather::Stanza::Message::VALID_TYPES' do
|
123
|
-
|
123
|
+
expect { Blather::Stanza::Message.new nil, nil, :invalid_type_name }.to 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
|
+
expect(msg.type).to eq(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
|
+
expect(Blather::Stanza::Message.new).to 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
|
+
expect(msg.find_first(*search_args)).to be_nil
|
144
144
|
|
145
145
|
msg.xhtml_node
|
146
|
-
msg.find_first(*search_args).
|
146
|
+
expect(msg.find_first(*search_args)).not_to 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
|
+
expect(msg.find_first(*search_args)).to be_nil
|
157
157
|
|
158
158
|
msg.xhtml_node
|
159
|
-
msg.find_first(*search_args).
|
159
|
+
expect(msg.find_first(*search_args)).not_to be_nil
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'returns an existing node when asked for xhtml_node' do
|
@@ -167,47 +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
|
+
expect(msg.xhtml_node).to eq(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
|
+
expect(msg.xhtml_node.inner_html.strip).to eq(xhtml)
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'sets valid xhtml even if the input is not valid' do
|
181
|
-
pending "Nokogiri doesn't handle invalid HTML on JRuby" if jruby?
|
182
181
|
msg = Blather::Stanza::Message.new
|
183
182
|
xhtml = "<some>xhtml"
|
184
183
|
msg.xhtml = xhtml
|
185
|
-
msg.xhtml_node.inner_html.strip.
|
184
|
+
expect(msg.xhtml_node.inner_html.strip).to eq("<some>xhtml</some>")
|
186
185
|
end
|
187
186
|
|
188
187
|
it 'sets xhtml with more than one root node' do
|
189
188
|
msg = Blather::Stanza::Message.new
|
190
189
|
xhtml = "<i>xhtml</i> more xhtml"
|
191
190
|
msg.xhtml = xhtml
|
192
|
-
msg.xhtml_node.inner_html.strip.
|
191
|
+
expect(msg.xhtml_node.inner_html.strip).to eq("<i>xhtml</i> more xhtml")
|
193
192
|
end
|
194
193
|
|
195
194
|
it 'has an xhtml getter' do
|
196
195
|
msg = Blather::Stanza::Message.new
|
197
196
|
xhtml = "<some>xhtml</some>"
|
198
197
|
msg.xhtml = xhtml
|
199
|
-
msg.xhtml.
|
198
|
+
expect(msg.xhtml).to eq(xhtml)
|
200
199
|
end
|
201
200
|
|
202
201
|
it 'finds xhtml body when html wrapper has wrong namespace' do
|
203
202
|
msg = Blather::XMPPNode.parse(ichat_message_xml)
|
204
|
-
Nokogiri::XML(msg.xhtml).to_xml.
|
203
|
+
expect(Nokogiri::XML(msg.xhtml).to_xml).to eq(Nokogiri::XML("<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>").to_xml)
|
205
204
|
end
|
206
205
|
|
207
206
|
it 'has a chat state setter' do
|
208
207
|
msg = Blather::Stanza::Message.new
|
209
208
|
msg.chat_state = :composing
|
210
|
-
msg.xpath('ns:composing', :ns => Blather::Stanza::Message::CHAT_STATE_NS).
|
209
|
+
expect(msg.xpath('ns:composing', :ns => Blather::Stanza::Message::CHAT_STATE_NS)).not_to be_empty
|
211
210
|
end
|
212
211
|
|
213
212
|
it 'will only add one chat state at a time' do
|
@@ -215,69 +214,69 @@ describe Blather::Stanza::Message do
|
|
215
214
|
msg.chat_state = :composing
|
216
215
|
msg.chat_state = :paused
|
217
216
|
|
218
|
-
msg.xpath('ns:*', :ns => Blather::Stanza::Message::CHAT_STATE_NS).size.
|
217
|
+
expect(msg.xpath('ns:*', :ns => Blather::Stanza::Message::CHAT_STATE_NS).size).to eq(1)
|
219
218
|
end
|
220
219
|
|
221
220
|
it 'ensures chat state setter accepts strings' do
|
222
221
|
msg = Blather::Stanza::Message.new
|
223
222
|
msg.chat_state = "gone"
|
224
|
-
msg.xpath('ns:gone', :ns => Blather::Stanza::Message::CHAT_STATE_NS).
|
223
|
+
expect(msg.xpath('ns:gone', :ns => Blather::Stanza::Message::CHAT_STATE_NS)).not_to be_empty
|
225
224
|
end
|
226
225
|
|
227
226
|
it 'ensures chat state is one of Blather::Stanza::Message::VALID_CHAT_STATES' do
|
228
|
-
|
227
|
+
expect do
|
229
228
|
msg = Blather::Stanza::Message.new
|
230
229
|
msg.chat_state = :invalid_chat_state
|
231
|
-
end.
|
230
|
+
end.to raise_error(Blather::ArgumentError)
|
232
231
|
|
233
232
|
Blather::Stanza::Message::VALID_CHAT_STATES.each do |valid_chat_state|
|
234
233
|
msg = Blather::Stanza::Message.new
|
235
234
|
msg.chat_state = valid_chat_state
|
236
|
-
msg.chat_state.
|
235
|
+
expect(msg.chat_state).to eq(valid_chat_state)
|
237
236
|
end
|
238
237
|
end
|
239
238
|
|
240
239
|
it 'has a chat state getter' do
|
241
240
|
msg = Blather::Stanza::Message.new
|
242
241
|
msg.chat_state = :paused
|
243
|
-
msg.chat_state.
|
242
|
+
expect(msg.chat_state).to eq(:paused)
|
244
243
|
end
|
245
244
|
|
246
245
|
it 'imports correct chat state' do
|
247
|
-
Blather::XMPPNode.parse(message_xml).chat_state.
|
246
|
+
expect(Blather::XMPPNode.parse(message_xml).chat_state).to eq(:paused)
|
248
247
|
end
|
249
248
|
|
250
249
|
it 'makes a form child available' do
|
251
250
|
n = Blather::XMPPNode.parse(message_xml)
|
252
|
-
n.form.fields.size.
|
253
|
-
n.form.fields.map { |f| f.class }.uniq.
|
254
|
-
n.form.
|
251
|
+
expect(n.form.fields.size).to eq(1)
|
252
|
+
expect(n.form.fields.map { |f| f.class }.uniq).to eq([Blather::Stanza::X::Field])
|
253
|
+
expect(n.form).to be_instance_of Blather::Stanza::X
|
255
254
|
|
256
255
|
r = Blather::Stanza::Message.new
|
257
256
|
r.form.type = :form
|
258
|
-
r.form.type.
|
257
|
+
expect(r.form.type).to eq(:form)
|
259
258
|
end
|
260
259
|
|
261
260
|
it 'ensures the form child is a direct child' do
|
262
261
|
r = Blather::Stanza::Message.new
|
263
262
|
r.form
|
264
|
-
r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).
|
263
|
+
expect(r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns)).not_to be_empty
|
265
264
|
end
|
266
265
|
|
267
266
|
it 'is not delayed' do
|
268
267
|
n = Blather::XMPPNode.parse(message_xml)
|
269
|
-
n.delay.
|
270
|
-
n.delayed
|
268
|
+
expect(n.delay).to eq(nil)
|
269
|
+
expect(n.delayed?).to eq(false)
|
271
270
|
end
|
272
271
|
|
273
272
|
describe "with a delay" do
|
274
273
|
it "is delayed" do
|
275
274
|
n = Blather::XMPPNode.parse(delayed_message_xml)
|
276
|
-
n.delayed
|
277
|
-
n.delay.
|
278
|
-
n.delay.from.
|
279
|
-
n.delay.stamp.
|
280
|
-
n.delay.description.
|
275
|
+
expect(n.delayed?).to eq(true)
|
276
|
+
expect(n.delay).to be_instance_of Blather::Stanza::Message::Delay
|
277
|
+
expect(n.delay.from).to eq('coven@chat.shakespeare.lit')
|
278
|
+
expect(n.delay.stamp).to eq(Time.utc(2002, 10, 13, 23, 58, 37, 0))
|
279
|
+
expect(n.delay.description).to eq("Too slow")
|
281
280
|
end
|
282
281
|
end
|
283
282
|
end
|