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
@@ -4,68 +4,68 @@ describe Blather::RosterItem do
|
|
4
4
|
it 'can be initialized with Blather::JID' do
|
5
5
|
jid = Blather::JID.new(jid)
|
6
6
|
i = Blather::RosterItem.new jid
|
7
|
-
i.jid.
|
7
|
+
expect(i.jid).to eq(jid)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'can be initialized with an Iq::RosterItem' do
|
11
11
|
jid = 'n@d/r'
|
12
12
|
i = Blather::RosterItem.new Blather::Stanza::Iq::Roster::RosterItem.new(jid)
|
13
|
-
i.jid.
|
13
|
+
expect(i.jid).to eq(Blather::JID.new(jid).stripped)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'can be initialized with a string' do
|
17
17
|
jid = 'n@d/r'
|
18
18
|
i = Blather::RosterItem.new jid
|
19
|
-
i.jid.
|
19
|
+
expect(i.jid).to eq(Blather::JID.new(jid).stripped)
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'returns the same object when intialized with a Blather::RosterItem' do
|
23
23
|
control = Blather::RosterItem.new 'n@d/r'
|
24
|
-
Blather::RosterItem.new(control).
|
24
|
+
expect(Blather::RosterItem.new(control)).to be control
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'has a Blather::JID setter that strips the Blather::JID' do
|
28
28
|
jid = Blather::JID.new('n@d/r')
|
29
29
|
i = Blather::RosterItem.new nil
|
30
30
|
i.jid = jid
|
31
|
-
i.jid.
|
31
|
+
expect(i.jid).to eq(jid.stripped)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'has a subscription setter that forces a symbol' do
|
35
35
|
i = Blather::RosterItem.new nil
|
36
36
|
i.subscription = 'remove'
|
37
|
-
i.subscription.
|
37
|
+
expect(i.subscription).to eq(:remove)
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'forces the type of subscription' do
|
41
|
-
|
41
|
+
expect { Blather::RosterItem.new(nil).subscription = 'foo' }.to raise_error Blather::ArgumentError
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'returns :none if the subscription field is blank' do
|
45
|
-
Blather::RosterItem.new(nil).subscription.
|
45
|
+
expect(Blather::RosterItem.new(nil).subscription).to eq(:none)
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'ensure #ask is a symbol' do
|
49
49
|
i = Blather::RosterItem.new(nil)
|
50
50
|
i.ask = 'subscribe'
|
51
|
-
i.ask.
|
51
|
+
expect(i.ask).to eq(:subscribe)
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'forces #ask to be :subscribe or nothing at all' do
|
55
|
-
|
55
|
+
expect { Blather::RosterItem.new(nil).ask = 'foo' }.to raise_error Blather::ArgumentError
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'generates a stanza with #to_stanza' do
|
59
59
|
jid = Blather::JID.new('n@d/r')
|
60
60
|
i = Blather::RosterItem.new jid
|
61
61
|
s = i.to_stanza
|
62
|
-
s.
|
63
|
-
s.items.first.jid.
|
62
|
+
expect(s).to be_kind_of Blather::Stanza::Iq::Roster
|
63
|
+
expect(s.items.first.jid).to eq(jid.stripped)
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'returns status based on priority' do
|
67
67
|
setup_item_with_presences
|
68
|
-
@i.status.
|
68
|
+
expect(@i.status).to eq(@p3)
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'returns status based on priority and state' do
|
@@ -77,12 +77,12 @@ describe Blather::RosterItem do
|
|
77
77
|
@p4.priority = 15
|
78
78
|
@i.status = @p4
|
79
79
|
|
80
|
-
@i.status.
|
80
|
+
expect(@i.status).to eq(@p3)
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'returns status based on resource' do
|
84
84
|
setup_item_with_presences
|
85
|
-
@i.status('a').
|
85
|
+
expect(@i.status('a')).to eq(@p)
|
86
86
|
end
|
87
87
|
|
88
88
|
def setup_item_with_presences
|
@@ -116,12 +116,12 @@ describe Blather::RosterItem do
|
|
116
116
|
@i.status = p
|
117
117
|
end
|
118
118
|
|
119
|
-
@i.statuses.size.
|
119
|
+
expect(@i.statuses.size).to eq(4)
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'initializes groups to [nil] if the item is not part of a group' do
|
123
123
|
i = Blather::RosterItem.new 'n@d'
|
124
|
-
i.groups.
|
124
|
+
expect(i.groups).to eq([nil])
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'can determine equality' do
|
@@ -129,6 +129,6 @@ describe Blather::RosterItem do
|
|
129
129
|
item2 = Blather::RosterItem.new 'n@d'
|
130
130
|
item1.groups = %w[group1 group2]
|
131
131
|
item2.groups = %w[group1 group2]
|
132
|
-
(item1 == item2).
|
132
|
+
expect(item1 == item2).to eq(true)
|
133
133
|
end
|
134
134
|
end
|
data/spec/blather/roster_spec.rb
CHANGED
@@ -14,31 +14,31 @@ describe Blather::Roster do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'initializes with items' do
|
17
|
-
@roster.items.map { |_,i| i.jid.to_s }.
|
17
|
+
expect(@roster.items.map { |_,i| i.jid.to_s }).to eq(@stanza.items.map { |i| i.jid.stripped.to_s }.uniq)
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'processes @stanzas with remove requests' do
|
21
21
|
s = @roster['n@d/0r']
|
22
22
|
s.subscription = :remove
|
23
|
-
|
23
|
+
expect { @roster.process(s.to_stanza) }.to change(@roster, :length).by -1
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'processes @stanzas with add requests' do
|
27
27
|
s = Blather::Stanza::Iq::Roster::RosterItem.new('a@b/c').to_stanza
|
28
|
-
|
28
|
+
expect { @roster.process(s) }.to change(@roster, :length).by 1
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'allows a jid to be pushed' do
|
32
32
|
jid = 'a@b/c'
|
33
|
-
|
34
|
-
@roster[jid].
|
33
|
+
expect { @roster.push(jid) }.to change(@roster, :length).by 1
|
34
|
+
expect(@roster[jid]).not_to be_nil
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'allows an item to be pushed' do
|
38
38
|
jid = 'a@b/c'
|
39
39
|
item = Blather::RosterItem.new(Blather::JID.new(jid))
|
40
|
-
|
41
|
-
@roster[jid].
|
40
|
+
expect { @roster.push(item) }.to change(@roster, :length).by 1
|
41
|
+
expect(@roster[jid]).not_to be_nil
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'aliases #<< to #push and returns self to allow for chaining' do
|
@@ -46,9 +46,9 @@ describe Blather::Roster do
|
|
46
46
|
item = Blather::RosterItem.new(Blather::JID.new(jid))
|
47
47
|
jid2 = 'd@e/f'
|
48
48
|
item2 = Blather::RosterItem.new(Blather::JID.new(jid2))
|
49
|
-
|
50
|
-
@roster[jid].
|
51
|
-
@roster[jid2].
|
49
|
+
expect { @roster << item << item2 }.to change(@roster, :length).by 2
|
50
|
+
expect(@roster[jid]).not_to be_nil
|
51
|
+
expect(@roster[jid2]).not_to be_nil
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'sends a @roster addition over the wire' do
|
@@ -58,7 +58,7 @@ describe Blather::Roster do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'removes a Blather::JID' do
|
61
|
-
|
61
|
+
expect { @roster.delete 'n@d' }.to change(@roster, :length).by -1
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'sends a @roster removal over the wire' do
|
@@ -69,26 +69,26 @@ describe Blather::Roster do
|
|
69
69
|
|
70
70
|
it 'returns an item through []' do
|
71
71
|
item = @roster['n@d']
|
72
|
-
item.
|
73
|
-
item.jid.
|
72
|
+
expect(item).to be_kind_of Blather::RosterItem
|
73
|
+
expect(item.jid).to eq(Blather::JID.new('n@d'))
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'responds to #each' do
|
77
|
-
@roster.
|
77
|
+
expect(@roster).to respond_to :each
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'cycles through all the items using #each' do
|
81
|
-
@roster.map { |i| i }.sort.
|
81
|
+
expect(@roster.map { |i| i }.sort).to eq(@roster.items.values.sort)
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'yields RosterItems from #each' do
|
85
|
-
@roster.map { |i| i.
|
85
|
+
@roster.map { |i| expect(i).to be_kind_of Blather::RosterItem }
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'returns a duplicate of items through #items' do
|
89
89
|
items = @roster.items
|
90
90
|
items.delete 'n@d'
|
91
|
-
items.
|
91
|
+
expect(items).not_to equal @roster.items
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'will group roster items' do
|
@@ -99,7 +99,7 @@ describe Blather::Roster do
|
|
99
99
|
item2.groups = ['group1', 'group3']
|
100
100
|
@roster << item1 << item2
|
101
101
|
|
102
|
-
@roster.grouped.
|
102
|
+
expect(@roster.grouped).to eq({
|
103
103
|
'group1' => [item1, item2],
|
104
104
|
'group2' => [item1],
|
105
105
|
'group3' => [item2]
|
@@ -21,60 +21,60 @@ end
|
|
21
21
|
|
22
22
|
describe Blather::Stanza::Iq::DiscoInfo do
|
23
23
|
it 'registers itself' do
|
24
|
-
Blather::XMPPNode.class_from_registration(:query, 'http://jabber.org/protocol/disco#info').
|
24
|
+
expect(Blather::XMPPNode.class_from_registration(:query, 'http://jabber.org/protocol/disco#info')).to eq(Blather::Stanza::Iq::DiscoInfo)
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'must be importable' do
|
28
|
-
Blather::XMPPNode.parse(disco_info_xml).
|
28
|
+
expect(Blather::XMPPNode.parse(disco_info_xml)).to be_instance_of Blather::Stanza::Iq::DiscoInfo
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'has a node attribute' do
|
32
32
|
n = Blather::Stanza::Iq::DiscoInfo.new nil, 'music', [], []
|
33
|
-
n.node.
|
33
|
+
expect(n.node).to eq('music')
|
34
34
|
n.node = :foo
|
35
|
-
n.node.
|
35
|
+
expect(n.node).to eq('foo')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'inherits a list of identities' do
|
39
39
|
n = parse_stanza disco_info_xml
|
40
40
|
r = Blather::Stanza::Iq::DiscoInfo.new.inherit n.root
|
41
|
-
r.identities.size.
|
42
|
-
r.identities.map { |i| i.class }.uniq.
|
41
|
+
expect(r.identities.size).to eq(1)
|
42
|
+
expect(r.identities.map { |i| i.class }.uniq).to eq([Blather::Stanza::Iq::DiscoInfo::Identity])
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'inherits a list of features' do
|
46
46
|
n = parse_stanza disco_info_xml
|
47
47
|
r = Blather::Stanza::Iq::DiscoInfo.new.inherit n.root
|
48
|
-
r.features.size.
|
49
|
-
r.features.map { |i| i.class }.uniq.
|
48
|
+
expect(r.features.size).to eq(2)
|
49
|
+
expect(r.features.map { |i| i.class }.uniq).to eq([Blather::Stanza::Iq::DiscoInfo::Feature])
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'is constructed properly' do
|
53
53
|
n = Blather::Stanza::Iq::DiscoInfo.new :get, '/path/to/node'
|
54
54
|
n.to = 'to@jid.com'
|
55
|
-
n.find("/iq[@to='to@jid.com' and @type='get' and @id='#{n.id}']/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::Iq::DiscoInfo.registered_ns).
|
55
|
+
expect(n.find("/iq[@to='to@jid.com' and @type='get' and @id='#{n.id}']/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::Iq::DiscoInfo.registered_ns)).not_to be_empty
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'allows adding of identities' do
|
59
59
|
di = Blather::Stanza::Iq::DiscoInfo.new
|
60
|
-
di.identities.size.
|
60
|
+
expect(di.identities.size).to eq(0)
|
61
61
|
di.identities = [{:name => 'name', :type => 'type', :category => 'category'}]
|
62
|
-
di.identities.size.
|
62
|
+
expect(di.identities.size).to eq(1)
|
63
63
|
di.identities += [Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type category])]
|
64
|
-
di.identities.size.
|
64
|
+
expect(di.identities.size).to eq(2)
|
65
65
|
di.identities = nil
|
66
|
-
di.identities.size.
|
66
|
+
expect(di.identities.size).to eq(0)
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'allows adding of features' do
|
70
70
|
di = Blather::Stanza::Iq::DiscoInfo.new
|
71
|
-
di.features.size.
|
71
|
+
expect(di.features.size).to eq(0)
|
72
72
|
di.features = ["feature1"]
|
73
|
-
di.features.size.
|
73
|
+
expect(di.features.size).to eq(1)
|
74
74
|
di.features += [Blather::Stanza::Iq::DiscoInfo::Feature.new("feature2")]
|
75
|
-
di.features.size.
|
75
|
+
expect(di.features.size).to eq(2)
|
76
76
|
di.features = nil
|
77
|
-
di.features.size.
|
77
|
+
expect(di.features.size).to eq(0)
|
78
78
|
end
|
79
79
|
|
80
80
|
end
|
@@ -90,8 +90,8 @@ describe 'Blather::Stanza::Iq::DiscoInfo identities' do
|
|
90
90
|
Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name1 type1 category1])]
|
91
91
|
|
92
92
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, ids
|
93
|
-
di.identities.size.
|
94
|
-
di.identities.each { |i| control.include?(i).
|
93
|
+
expect(di.identities.size).to eq(2)
|
94
|
+
di.identities.each { |i| expect(control.include?(i)).to eq(true) }
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'takes a list of Identity objects as identities' do
|
@@ -99,24 +99,24 @@ describe 'Blather::Stanza::Iq::DiscoInfo identities' do
|
|
99
99
|
Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name1 type1 category1])]
|
100
100
|
|
101
101
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, control
|
102
|
-
di.identities.size.
|
103
|
-
di.identities.each { |i| control.include?(i).
|
102
|
+
expect(di.identities.size).to eq(2)
|
103
|
+
di.identities.each { |i| expect(control.include?(i)).to eq(true) }
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'takes a single hash as identity' do
|
107
107
|
control = [Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type category])]
|
108
108
|
|
109
109
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, {:name => 'name', :type => 'type', :category => 'category'}
|
110
|
-
di.identities.size.
|
111
|
-
di.identities.each { |i| control.include?(i).
|
110
|
+
expect(di.identities.size).to eq(1)
|
111
|
+
di.identities.each { |i| expect(control.include?(i)).to eq(true) }
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'takes a single identity object as identity' do
|
115
115
|
control = [Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type category])]
|
116
116
|
|
117
117
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, control.first
|
118
|
-
di.identities.size.
|
119
|
-
di.identities.each { |i| control.include?(i).
|
118
|
+
expect(di.identities.size).to eq(1)
|
119
|
+
di.identities.each { |i| expect(control.include?(i)).to eq(true) }
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'takes a mix of hashes and identity objects as identities' do
|
@@ -129,8 +129,8 @@ describe 'Blather::Stanza::Iq::DiscoInfo identities' do
|
|
129
129
|
Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name1 type1 category1])]
|
130
130
|
|
131
131
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, ids
|
132
|
-
di.identities.size.
|
133
|
-
di.identities.each { |i| control.include?(i).
|
132
|
+
expect(di.identities.size).to eq(2)
|
133
|
+
di.identities.each { |i| expect(control.include?(i)).to eq(true) }
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -140,8 +140,8 @@ describe 'Blather::Stanza::Iq::DiscoInfo features' do
|
|
140
140
|
control = features.map { |f| Blather::Stanza::Iq::DiscoInfo::Feature.new f }
|
141
141
|
|
142
142
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, [], features
|
143
|
-
di.features.size.
|
144
|
-
di.features.each { |f| control.include?(f).
|
143
|
+
expect(di.features.size).to eq(3)
|
144
|
+
di.features.each { |f| expect(control.include?(f)).to eq(true) }
|
145
145
|
end
|
146
146
|
|
147
147
|
it 'takes a list of features as Feature objects' do
|
@@ -149,24 +149,24 @@ describe 'Blather::Stanza::Iq::DiscoInfo features' do
|
|
149
149
|
control = features.map { |f| Blather::Stanza::Iq::DiscoInfo::Feature.new f }
|
150
150
|
|
151
151
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, [], control
|
152
|
-
di.features.size.
|
153
|
-
di.features.each { |f| control.include?(f).
|
152
|
+
expect(di.features.size).to eq(3)
|
153
|
+
di.features.each { |f| expect(control.include?(f)).to eq(true) }
|
154
154
|
end
|
155
155
|
|
156
156
|
it 'takes a single string' do
|
157
157
|
control = [Blather::Stanza::Iq::DiscoInfo::Feature.new('feature1')]
|
158
158
|
|
159
159
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, [], 'feature1'
|
160
|
-
di.features.size.
|
161
|
-
di.features.each { |f| control.include?(f).
|
160
|
+
expect(di.features.size).to eq(1)
|
161
|
+
di.features.each { |f| expect(control.include?(f)).to eq(true) }
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'takes a single Feature object' do
|
165
165
|
control = [Blather::Stanza::Iq::DiscoInfo::Feature.new('feature1')]
|
166
166
|
|
167
167
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, [], control.first
|
168
|
-
di.features.size.
|
169
|
-
di.features.each { |f| control.include?(f).
|
168
|
+
expect(di.features.size).to eq(1)
|
169
|
+
di.features.each { |f| expect(control.include?(f)).to eq(true) }
|
170
170
|
end
|
171
171
|
|
172
172
|
it 'takes a mixed list of features as Feature objects and strings' do
|
@@ -175,8 +175,8 @@ describe 'Blather::Stanza::Iq::DiscoInfo features' do
|
|
175
175
|
features[1] = control[1]
|
176
176
|
|
177
177
|
di = Blather::Stanza::Iq::DiscoInfo.new nil, nil, [], features
|
178
|
-
di.features.size.
|
179
|
-
di.features.each { |f| control.include?(f).
|
178
|
+
expect(di.features.size).to eq(3)
|
179
|
+
di.features.each { |f| expect(control.include?(f)).to eq(true) }
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -184,44 +184,44 @@ describe Blather::Stanza::Iq::DiscoInfo::Identity do
|
|
184
184
|
it 'will auto-inherit nodes' do
|
185
185
|
n = parse_stanza "<identity name='Personal Events' type='pep' category='pubsub' node='publish' xml:lang='en' />"
|
186
186
|
i = Blather::Stanza::Iq::DiscoInfo::Identity.new n.root
|
187
|
-
i.name.
|
188
|
-
i.type.
|
189
|
-
i.category.
|
190
|
-
i.xml_lang.
|
187
|
+
expect(i.name).to eq('Personal Events')
|
188
|
+
expect(i.type).to eq(:pep)
|
189
|
+
expect(i.category).to eq(:pubsub)
|
190
|
+
expect(i.xml_lang).to eq('en')
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'has a category attribute' do
|
194
194
|
n = Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type cat])
|
195
|
-
n.category.
|
195
|
+
expect(n.category).to eq(:cat)
|
196
196
|
n.category = :foo
|
197
|
-
n.category.
|
197
|
+
expect(n.category).to eq(:foo)
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'has a type attribute' do
|
201
201
|
n = Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type cat])
|
202
|
-
n.type.
|
202
|
+
expect(n.type).to eq(:type)
|
203
203
|
n.type = :foo
|
204
|
-
n.type.
|
204
|
+
expect(n.type).to eq(:foo)
|
205
205
|
end
|
206
206
|
|
207
207
|
it 'has a name attribute' do
|
208
208
|
n = Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type cat])
|
209
|
-
n.name.
|
209
|
+
expect(n.name).to eq('name')
|
210
210
|
n.name = :foo
|
211
|
-
n.name.
|
211
|
+
expect(n.name).to eq('foo')
|
212
212
|
end
|
213
213
|
|
214
214
|
it 'has an xml:lang attribute' do
|
215
215
|
n = Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type cat en])
|
216
|
-
n.xml_lang.
|
216
|
+
expect(n.xml_lang).to eq('en')
|
217
217
|
n.xml_lang = 'de'
|
218
|
-
n.xml_lang.
|
218
|
+
expect(n.xml_lang).to eq('de')
|
219
219
|
end
|
220
220
|
|
221
221
|
it 'can determine equality' do
|
222
222
|
a = Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type cat])
|
223
|
-
a.
|
224
|
-
a.
|
223
|
+
expect(a).to eq(Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[name type cat]))
|
224
|
+
expect(a).not_to equal Blather::Stanza::Iq::DiscoInfo::Identity.new(*%w[not-name not-type not-cat])
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
@@ -229,19 +229,19 @@ describe Blather::Stanza::Iq::DiscoInfo::Feature do
|
|
229
229
|
it 'will auto-inherit nodes' do
|
230
230
|
n = parse_stanza "<feature var='ipv6' />"
|
231
231
|
i = Blather::Stanza::Iq::DiscoInfo::Feature.new n.root
|
232
|
-
i.var.
|
232
|
+
expect(i.var).to eq('ipv6')
|
233
233
|
end
|
234
234
|
|
235
235
|
it 'has a var attribute' do
|
236
236
|
n = Blather::Stanza::Iq::DiscoInfo::Feature.new 'var'
|
237
|
-
n.var.
|
237
|
+
expect(n.var).to eq('var')
|
238
238
|
n.var = :foo
|
239
|
-
n.var.
|
239
|
+
expect(n.var).to eq('foo')
|
240
240
|
end
|
241
241
|
|
242
242
|
it 'can determine equality' do
|
243
243
|
a = Blather::Stanza::Iq::DiscoInfo::Feature.new('var')
|
244
|
-
a.
|
245
|
-
a.
|
244
|
+
expect(a).to eq(Blather::Stanza::Iq::DiscoInfo::Feature.new('var'))
|
245
|
+
expect(a).not_to equal Blather::Stanza::Iq::DiscoInfo::Feature.new('not-var')
|
246
246
|
end
|
247
247
|
end
|