blather 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -13,44 +13,44 @@ end
|
|
13
13
|
|
14
14
|
describe 'Blather::Stanza::Presence::C' do
|
15
15
|
it 'registers itself' do
|
16
|
-
Blather::XMPPNode.class_from_registration(:c, 'http://jabber.org/protocol/caps' ).
|
16
|
+
expect(Blather::XMPPNode.class_from_registration(:c, 'http://jabber.org/protocol/caps' )).to eq(Blather::Stanza::Presence::C)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'must be importable' do
|
20
20
|
c = Blather::XMPPNode.parse c_xml
|
21
|
-
c.
|
22
|
-
c.hash.
|
23
|
-
c.node.
|
24
|
-
c.ver.
|
21
|
+
expect(c).to be_kind_of Blather::Stanza::Presence::C::InstanceMethods
|
22
|
+
expect(c.hash).to eq(:'sha-1')
|
23
|
+
expect(c.node).to eq('http://www.chatopus.com')
|
24
|
+
expect(c.ver).to eq('zHyEOgxTrkpSdGcQKH8EFPLsriY=')
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'ensures hash is one of Blather::Stanza::Presence::C::VALID_HASH_TYPES' do
|
28
|
-
|
28
|
+
expect { Blather::Stanza::Presence::C.new nil, nil, :invalid_type_name }.to raise_error(Blather::ArgumentError)
|
29
29
|
|
30
30
|
Blather::Stanza::Presence::C::VALID_HASH_TYPES.each do |valid_hash|
|
31
31
|
c = Blather::Stanza::Presence::C.new nil, nil, valid_hash
|
32
|
-
c.hash.
|
32
|
+
expect(c.hash).to eq(valid_hash.to_sym)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'can set a hash on creation' do
|
37
37
|
c = Blather::Stanza::Presence::C.new nil, nil, :md5
|
38
|
-
c.hash.
|
38
|
+
expect(c.hash).to eq(:md5)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'can set a node on creation' do
|
42
42
|
c = Blather::Stanza::Presence::C.new 'http://www.chatopus.com'
|
43
|
-
c.node.
|
43
|
+
expect(c.node).to eq('http://www.chatopus.com')
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'can set a ver on creation' do
|
47
47
|
c = Blather::Stanza::Presence::C.new nil, 'zHyEOgxTrkpSdGcQKH8EFPLsriY='
|
48
|
-
c.ver.
|
48
|
+
expect(c.ver).to eq('zHyEOgxTrkpSdGcQKH8EFPLsriY=')
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'is equal on import and creation' do
|
52
52
|
p = Blather::XMPPNode.parse c_xml
|
53
53
|
c = Blather::Stanza::Presence::C.new 'http://www.chatopus.com', 'zHyEOgxTrkpSdGcQKH8EFPLsriY=', 'sha-1'
|
54
|
-
p.
|
54
|
+
expect(p).to eq(c)
|
55
55
|
end
|
56
56
|
end
|
@@ -12,26 +12,26 @@ end
|
|
12
12
|
|
13
13
|
describe 'Blather::Stanza::Presence::MUC' do
|
14
14
|
it 'registers itself' do
|
15
|
-
Blather::XMPPNode.class_from_registration(:x, 'http://jabber.org/protocol/muc' ).
|
15
|
+
expect(Blather::XMPPNode.class_from_registration(:x, 'http://jabber.org/protocol/muc' )).to eq(Blather::Stanza::Presence::MUC)
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'must be importable' do
|
19
19
|
c = Blather::XMPPNode.parse(muc_xml)
|
20
|
-
c.
|
21
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns).count.
|
20
|
+
expect(c).to be_kind_of Blather::Stanza::Presence::MUC::InstanceMethods
|
21
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns).count).to eq(1)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'ensures a form node is present on create' do
|
25
25
|
c = Blather::Stanza::Presence::MUC.new
|
26
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns).
|
26
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns)).not_to be_empty
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'ensures a form node exists when calling #muc' do
|
30
30
|
c = Blather::Stanza::Presence::MUC.new
|
31
31
|
c.remove_children :x
|
32
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns).
|
32
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns)).to be_empty
|
33
33
|
|
34
|
-
c.muc.
|
35
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns).
|
34
|
+
expect(c.muc).not_to be_nil
|
35
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns)).not_to be_empty
|
36
36
|
end
|
37
37
|
end
|
@@ -20,64 +20,64 @@ end
|
|
20
20
|
describe 'Blather::Stanza::Presence::MUCUser' do
|
21
21
|
it 'must be importable' do
|
22
22
|
muc_user = Blather::XMPPNode.parse(muc_user_xml)
|
23
|
-
muc_user.
|
24
|
-
muc_user.affiliation.
|
25
|
-
muc_user.jid.
|
26
|
-
muc_user.role.
|
27
|
-
muc_user.status_codes.
|
28
|
-
muc_user.password.
|
23
|
+
expect(muc_user).to be_kind_of Blather::Stanza::Presence::MUCUser::InstanceMethods
|
24
|
+
expect(muc_user.affiliation).to eq(:none)
|
25
|
+
expect(muc_user.jid).to eq('hag66@shakespeare.lit/pda')
|
26
|
+
expect(muc_user.role).to eq(:participant)
|
27
|
+
expect(muc_user.status_codes).to eq([100, 110])
|
28
|
+
expect(muc_user.password).to eq('foobar')
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'ensures a form node is present on create' do
|
32
32
|
c = Blather::Stanza::Presence::MUCUser.new
|
33
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns).
|
33
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns)).not_to be_empty
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'ensures a form node exists when calling #muc' do
|
37
37
|
c = Blather::Stanza::Presence::MUCUser.new
|
38
38
|
c.remove_children :x
|
39
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns).
|
39
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns)).to be_empty
|
40
40
|
|
41
|
-
c.muc_user.
|
42
|
-
c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns).
|
41
|
+
expect(c.muc_user).not_to be_nil
|
42
|
+
expect(c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns)).not_to be_empty
|
43
43
|
end
|
44
44
|
|
45
45
|
it "must be able to set the affiliation" do
|
46
46
|
muc_user = Blather::Stanza::Presence::MUCUser.new
|
47
|
-
muc_user.affiliation.
|
47
|
+
expect(muc_user.affiliation).to eq(nil)
|
48
48
|
muc_user.affiliation = :none
|
49
|
-
muc_user.affiliation.
|
49
|
+
expect(muc_user.affiliation).to eq(:none)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "must be able to set the role" do
|
53
53
|
muc_user = Blather::Stanza::Presence::MUCUser.new
|
54
|
-
muc_user.role.
|
54
|
+
expect(muc_user.role).to eq(nil)
|
55
55
|
muc_user.role = :participant
|
56
|
-
muc_user.role.
|
56
|
+
expect(muc_user.role).to eq(:participant)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "must be able to set the jid" do
|
60
60
|
muc_user = Blather::Stanza::Presence::MUCUser.new
|
61
|
-
muc_user.jid.
|
61
|
+
expect(muc_user.jid).to eq(nil)
|
62
62
|
muc_user.jid = 'foo@bar.com'
|
63
|
-
muc_user.jid.
|
63
|
+
expect(muc_user.jid).to eq('foo@bar.com')
|
64
64
|
end
|
65
65
|
|
66
66
|
it "must be able to set the status codes" do
|
67
67
|
muc_user = Blather::Stanza::Presence::MUCUser.new
|
68
|
-
muc_user.status_codes.
|
68
|
+
expect(muc_user.status_codes).to eq([])
|
69
69
|
muc_user.status_codes = [100, 110]
|
70
|
-
muc_user.status_codes.
|
70
|
+
expect(muc_user.status_codes).to eq([100, 110])
|
71
71
|
muc_user.status_codes = [500]
|
72
|
-
muc_user.status_codes.
|
72
|
+
expect(muc_user.status_codes).to eq([500])
|
73
73
|
end
|
74
74
|
|
75
75
|
it "must be able to set the password" do
|
76
76
|
muc_user = Blather::Stanza::Presence::MUCUser.new
|
77
|
-
muc_user.password.
|
77
|
+
expect(muc_user.password).to eq(nil)
|
78
78
|
muc_user.password = 'barbaz'
|
79
|
-
muc_user.password.
|
79
|
+
expect(muc_user.password).to eq('barbaz')
|
80
80
|
muc_user.password = 'hello_world'
|
81
|
-
muc_user.password.
|
81
|
+
expect(muc_user.password).to eq('hello_world')
|
82
82
|
end
|
83
83
|
end
|
@@ -2,15 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blather::Stanza::Presence::Status do
|
4
4
|
it 'registers itself' do
|
5
|
-
Blather::XMPPNode.class_from_registration(:status, nil).
|
5
|
+
expect(Blather::XMPPNode.class_from_registration(:status, nil)).to eq(Blather::Stanza::Presence::Status)
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'must be importable as unavailable' do
|
9
|
-
Blather::XMPPNode.parse('<presence type="unavailable"/>').
|
9
|
+
expect(Blather::XMPPNode.parse('<presence type="unavailable"/>')).to be_kind_of Blather::Stanza::Presence::Status::InstanceMethods
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'must be importable as nil' do
|
13
|
-
Blather::XMPPNode.parse('<presence/>').
|
13
|
+
expect(Blather::XMPPNode.parse('<presence/>')).to be_kind_of Blather::Stanza::Presence::Status::InstanceMethods
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'must be importable with show, status and priority children' do
|
@@ -21,83 +21,83 @@ describe Blather::Stanza::Presence::Status do
|
|
21
21
|
<priority>10</priority>
|
22
22
|
</presence>
|
23
23
|
XML
|
24
|
-
n.
|
25
|
-
n.state.
|
26
|
-
n.message.
|
27
|
-
n.priority.
|
24
|
+
expect(n).to be_kind_of Blather::Stanza::Presence::Status::InstanceMethods
|
25
|
+
expect(n.state).to eq(:chat)
|
26
|
+
expect(n.message).to eq('Talk to me!')
|
27
|
+
expect(n.priority).to eq(10)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'can set state on creation' do
|
31
31
|
status = Blather::Stanza::Presence::Status.new :away
|
32
|
-
status.state.
|
32
|
+
expect(status.state).to eq(:away)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'can set a message on creation' do
|
36
36
|
status = Blather::Stanza::Presence::Status.new nil, 'Say hello!'
|
37
|
-
status.message.
|
37
|
+
expect(status.message).to eq('Say hello!')
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'ensures type is nil or :unavailable' do
|
41
41
|
status = Blather::Stanza::Presence::Status.new
|
42
|
-
|
42
|
+
expect { status.type = :invalid_type_name }.to raise_error(Blather::ArgumentError)
|
43
43
|
|
44
44
|
[nil, :unavailable].each do |valid_type|
|
45
45
|
status.type = valid_type
|
46
|
-
status.type.
|
46
|
+
expect(status.type).to eq(valid_type)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'ensures state is one of Presence::Status::VALID_STATES' do
|
51
51
|
status = Blather::Stanza::Presence::Status.new
|
52
|
-
|
52
|
+
expect { status.state = :invalid_type_name }.to raise_error(Blather::ArgumentError)
|
53
53
|
|
54
54
|
Blather::Stanza::Presence::Status::VALID_STATES.each do |valid_state|
|
55
55
|
status.state = valid_state
|
56
|
-
status.state.
|
56
|
+
expect(status.state).to eq(valid_state)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'returns :available if state is nil' do
|
61
|
-
Blather::Stanza::Presence::Status.new.state.
|
61
|
+
expect(Blather::Stanza::Presence::Status.new.state).to eq(:available)
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'returns :available if <show/> is blank' do
|
65
65
|
status = Blather::XMPPNode.parse(<<-NODE)
|
66
66
|
<presence><show/></presence>
|
67
67
|
NODE
|
68
|
-
status.state.
|
68
|
+
expect(status.state).to eq(:available)
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'returns :unavailable if type is :unavailable' do
|
72
72
|
status = Blather::Stanza::Presence::Status.new
|
73
73
|
status.type = :unavailable
|
74
|
-
status.state.
|
74
|
+
expect(status.state).to eq(:unavailable)
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'ensures priority is not greater than 127' do
|
78
|
-
|
78
|
+
expect { Blather::Stanza::Presence::Status.new.priority = 128 }.to raise_error(Blather::ArgumentError)
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'ensures priority is not less than -128' do
|
82
|
-
|
82
|
+
expect { Blather::Stanza::Presence::Status.new.priority = -129 }.to raise_error(Blather::ArgumentError)
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'has "attr_accessor" for priority' do
|
86
86
|
status = Blather::Stanza::Presence::Status.new
|
87
|
-
status.priority.
|
87
|
+
expect(status.priority).to eq(0)
|
88
88
|
|
89
89
|
status.priority = 10
|
90
|
-
status.children.detect { |n| n.element_name == 'priority' }.
|
91
|
-
status.priority.
|
90
|
+
expect(status.children.detect { |n| n.element_name == 'priority' }).not_to be_nil
|
91
|
+
expect(status.priority).to eq(10)
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'has "attr_accessor" for message' do
|
95
95
|
status = Blather::Stanza::Presence::Status.new
|
96
|
-
status.message.
|
96
|
+
expect(status.message).to be_nil
|
97
97
|
|
98
98
|
status.message = 'new message'
|
99
|
-
status.children.detect { |n| n.element_name == 'status' }.
|
100
|
-
status.message.
|
99
|
+
expect(status.children.detect { |n| n.element_name == 'status' }).not_to be_nil
|
100
|
+
expect(status.message).to eq('new message')
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'must be comparable by priority' do
|
@@ -111,11 +111,11 @@ describe Blather::Stanza::Presence::Status do
|
|
111
111
|
|
112
112
|
status1.priority = 1
|
113
113
|
status2.priority = -1
|
114
|
-
(status1 <=> status2).
|
115
|
-
(status2 <=> status1).
|
114
|
+
expect(status1 <=> status2).to eq(1)
|
115
|
+
expect(status2 <=> status1).to eq(-1)
|
116
116
|
|
117
117
|
status2.priority = 1
|
118
|
-
(status1 <=> status2).
|
118
|
+
expect(status1 <=> status2).to eq(0)
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'must should sort by status if priorities are equal' do
|
@@ -128,8 +128,8 @@ describe Blather::Stanza::Presence::Status do
|
|
128
128
|
status2.from = jid
|
129
129
|
|
130
130
|
status1.priority = status2.priority = 1
|
131
|
-
(status1 <=> status2).
|
132
|
-
(status2 <=> status1).
|
131
|
+
expect(status1 <=> status2).to eq(-1)
|
132
|
+
expect(status2 <=> status1).to eq(1)
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'raises an argument error if compared to a status with a different Blather::JID' do
|
@@ -139,20 +139,20 @@ describe Blather::Stanza::Presence::Status do
|
|
139
139
|
status2 = Blather::Stanza::Presence::Status.new
|
140
140
|
status2.from = 'd@e/f'
|
141
141
|
|
142
|
-
|
142
|
+
expect { status1 <=> status2 }.to raise_error(Blather::ArgumentError)
|
143
143
|
end
|
144
144
|
|
145
145
|
([:available] + Blather::Stanza::Presence::Status::VALID_STATES).each do |valid_state|
|
146
146
|
it "provides a helper (#{valid_state}?) for state #{valid_state}" do
|
147
|
-
Blather::Stanza::Presence::Status.new.
|
147
|
+
expect(Blather::Stanza::Presence::Status.new).to respond_to :"#{valid_state}?"
|
148
148
|
end
|
149
149
|
|
150
150
|
it "returns true on call to (#{valid_state}?) if state == #{valid_state}" do
|
151
151
|
method = "#{valid_state}?".to_sym
|
152
152
|
stat = Blather::Stanza::Presence::Status.new
|
153
153
|
stat.state = valid_state
|
154
|
-
stat.
|
155
|
-
stat.__send__(method).
|
154
|
+
expect(stat).to respond_to method
|
155
|
+
expect(stat.__send__(method)).to eq(true)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -2,35 +2,35 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blather::Stanza::Presence::Subscription do
|
4
4
|
it 'registers itself' do
|
5
|
-
Blather::XMPPNode.class_from_registration(:subscription, nil).
|
5
|
+
expect(Blather::XMPPNode.class_from_registration(:subscription, nil)).to eq(Blather::Stanza::Presence::Subscription)
|
6
6
|
end
|
7
7
|
|
8
8
|
[:subscribe, :subscribed, :unsubscribe, :unsubscribed].each do |type|
|
9
9
|
it "must be importable as #{type}" do
|
10
|
-
Blather::XMPPNode.parse("<presence type='#{type}'/>").
|
10
|
+
expect(Blather::XMPPNode.parse("<presence type='#{type}'/>")).to be_kind_of Blather::Stanza::Presence::Subscription::InstanceMethods
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'can set to on creation' do
|
15
15
|
sub = Blather::Stanza::Presence::Subscription.new 'a@b'
|
16
|
-
sub.to.to_s.
|
16
|
+
expect(sub.to.to_s).to eq('a@b')
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'can set a type on creation' do
|
20
20
|
sub = Blather::Stanza::Presence::Subscription.new nil, :subscribed
|
21
|
-
sub.type.
|
21
|
+
expect(sub.type).to eq(:subscribed)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'strips Blather::JIDs when setting #to' do
|
25
25
|
sub = Blather::Stanza::Presence::Subscription.new 'a@b/c'
|
26
|
-
sub.to.to_s.
|
26
|
+
expect(sub.to.to_s).to eq('a@b')
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'generates an approval using #approve!' do
|
30
30
|
sub = Blather::Stanza.import Nokogiri::XML('<presence from="a@b" type="subscribe"><status/></presence>').root
|
31
31
|
sub.approve!
|
32
|
-
sub.to.
|
33
|
-
sub.type.
|
32
|
+
expect(sub.to).to eq('a@b')
|
33
|
+
expect(sub.type).to eq(:subscribed)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'generates a refusal using #refuse!' do
|
@@ -38,8 +38,8 @@ describe Blather::Stanza::Presence::Subscription do
|
|
38
38
|
sub = Blather::Stanza::Presence::Subscription.new
|
39
39
|
sub.from = jid
|
40
40
|
sub.refuse!
|
41
|
-
sub.to.
|
42
|
-
sub.type.
|
41
|
+
expect(sub.to).to eq(jid)
|
42
|
+
expect(sub.type).to eq(:unsubscribed)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'generates an unsubscript using #unsubscribe!' do
|
@@ -47,8 +47,8 @@ describe Blather::Stanza::Presence::Subscription do
|
|
47
47
|
sub = Blather::Stanza::Presence::Subscription.new
|
48
48
|
sub.from = jid
|
49
49
|
sub.unsubscribe!
|
50
|
-
sub.to.
|
51
|
-
sub.type.
|
50
|
+
expect(sub.to).to eq(jid)
|
51
|
+
expect(sub.type).to eq(:unsubscribe)
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'generates a cancellation using #cancel!' do
|
@@ -56,8 +56,8 @@ describe Blather::Stanza::Presence::Subscription do
|
|
56
56
|
sub = Blather::Stanza::Presence::Subscription.new
|
57
57
|
sub.from = jid
|
58
58
|
sub.cancel!
|
59
|
-
sub.to.
|
60
|
-
sub.type.
|
59
|
+
expect(sub.to).to eq(jid)
|
60
|
+
expect(sub.type).to eq(:unsubscribed)
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'generates a request using #request!' do
|
@@ -65,15 +65,15 @@ describe Blather::Stanza::Presence::Subscription do
|
|
65
65
|
sub = Blather::Stanza::Presence::Subscription.new
|
66
66
|
sub.from = jid
|
67
67
|
sub.request!
|
68
|
-
sub.to.
|
69
|
-
sub.type.
|
68
|
+
expect(sub.to).to eq(jid)
|
69
|
+
expect(sub.type).to eq(:subscribe)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'has a #request? helper' do
|
73
73
|
sub = Blather::Stanza::Presence::Subscription.new
|
74
|
-
sub.
|
74
|
+
expect(sub).to respond_to :request?
|
75
75
|
sub.type = :subscribe
|
76
|
-
sub.request
|
76
|
+
expect(sub.request?).to eq(true)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "successfully routes chained actions" do
|
@@ -84,9 +84,9 @@ describe Blather::Stanza::Presence::Subscription do
|
|
84
84
|
sub.to = to
|
85
85
|
sub.cancel!
|
86
86
|
sub.unsubscribe!
|
87
|
-
sub.type.
|
88
|
-
sub.to.
|
89
|
-
sub.from.
|
87
|
+
expect(sub.type).to eq(:unsubscribe)
|
88
|
+
expect(sub.to).to eq(from)
|
89
|
+
expect(sub.from).to eq(to)
|
90
90
|
end
|
91
91
|
|
92
92
|
it "will inherit only another node's attributes" do
|
@@ -94,9 +94,9 @@ describe Blather::Stanza::Presence::Subscription do
|
|
94
94
|
inheritable[:bar] = 'baz'
|
95
95
|
|
96
96
|
sub = Blather::Stanza::Presence::Subscription.new
|
97
|
-
sub.
|
97
|
+
expect(sub).to respond_to :inherit
|
98
98
|
|
99
99
|
sub.inherit inheritable
|
100
|
-
sub[:bar].
|
100
|
+
expect(sub[:bar]).to eq('baz')
|
101
101
|
end
|
102
102
|
end
|