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
@@ -3,72 +3,72 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Unsubscribe do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:unsubscribe, 'http://jabber.org/protocol/pubsub').
|
6
|
+
Blather::XMPPNode.class_from_registration(:unsubscribe, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Unsubscribe
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.
|
10
|
+
Blather::XMPPNode.parse(unsubscribe_xml).should be_instance_of Blather::Stanza::PubSub::Unsubscribe
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'ensures an unsubscribe node is present on create' do
|
14
14
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
|
15
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).
|
15
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'ensures an unsubscribe node exists when calling #unsubscribe' do
|
19
19
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
|
20
20
|
unsubscribe.pubsub.remove_children :unsubscribe
|
21
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).
|
21
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
22
|
|
23
|
-
unsubscribe.unsubscribe.
|
24
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
unsubscribe.unsubscribe.should_not be_nil
|
24
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'defaults to a set node' do
|
28
28
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
|
29
|
-
unsubscribe.type.
|
29
|
+
unsubscribe.type.should == :set
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'sets the host if requested' do
|
33
33
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'pubsub.jabber.local', 'node', 'jid'
|
34
|
-
unsubscribe.to.
|
34
|
+
unsubscribe.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'sets the node' do
|
38
38
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
39
|
-
unsubscribe.node.
|
39
|
+
unsubscribe.node.should == 'node-name'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'has a node attribute' do
|
43
43
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
44
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
45
|
-
unsubscribe.node.
|
44
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
45
|
+
unsubscribe.node.should == 'node-name'
|
46
46
|
|
47
47
|
unsubscribe.node = 'new-node'
|
48
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
49
|
-
unsubscribe.node.
|
48
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
49
|
+
unsubscribe.node.should == 'new-node'
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'has a jid attribute' do
|
53
53
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
54
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
55
|
-
unsubscribe.jid.
|
54
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
55
|
+
unsubscribe.jid.should == Blather::JID.new('jid')
|
56
56
|
|
57
57
|
unsubscribe.jid = Blather::JID.new('n@d/r')
|
58
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
59
|
-
unsubscribe.jid.
|
58
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
59
|
+
unsubscribe.jid.should == Blather::JID.new('n@d/r')
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'has a subid attribute' do
|
63
63
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
|
64
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
64
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
65
65
|
|
66
66
|
unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid', 'subid'
|
67
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
68
|
-
unsubscribe.subid.
|
67
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
68
|
+
unsubscribe.subid.should == 'subid'
|
69
69
|
|
70
70
|
unsubscribe.subid = 'newsubid'
|
71
|
-
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="newsubid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
72
|
-
unsubscribe.subid.
|
71
|
+
unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="newsubid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
72
|
+
unsubscribe.subid.should == 'newsubid'
|
73
73
|
end
|
74
74
|
end
|
@@ -3,11 +3,11 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSubOwner::Delete do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:delete, 'http://jabber.org/protocol/pubsub#owner').
|
6
|
+
Blather::XMPPNode.class_from_registration(:delete, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner::Delete
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.
|
10
|
+
Blather::XMPPNode.parse(<<-NODE).should be_instance_of Blather::Stanza::PubSubOwner::Delete
|
11
11
|
<iq type='set'
|
12
12
|
from='hamlet@denmark.lit/elsinore'
|
13
13
|
to='pubsub.shakespeare.lit'
|
@@ -21,30 +21,30 @@ describe Blather::Stanza::PubSubOwner::Delete do
|
|
21
21
|
|
22
22
|
it 'ensures an delete node is present on delete' do
|
23
23
|
delete = Blather::Stanza::PubSubOwner::Delete.new
|
24
|
-
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
24
|
+
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'ensures an delete node exists when calling #delete_node' do
|
28
28
|
delete = Blather::Stanza::PubSubOwner::Delete.new
|
29
29
|
delete.pubsub.remove_children :delete
|
30
|
-
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
30
|
+
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_empty
|
31
31
|
|
32
|
-
delete.delete_node.
|
33
|
-
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
32
|
+
delete.delete_node.should_not be_nil
|
33
|
+
delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'defaults to a set node' do
|
37
37
|
delete = Blather::Stanza::PubSubOwner::Delete.new
|
38
|
-
delete.type.
|
38
|
+
delete.type.should == :set
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'sets the host if requested' do
|
42
42
|
delete = Blather::Stanza::PubSubOwner::Delete.new :set, 'pubsub.jabber.local'
|
43
|
-
delete.to.
|
43
|
+
delete.to.should == Blather::JID.new('pubsub.jabber.local')
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'sets the node' do
|
47
47
|
delete = Blather::Stanza::PubSubOwner::Delete.new :set, 'host', 'node-name'
|
48
|
-
delete.node.
|
48
|
+
delete.node.should == 'node-name'
|
49
49
|
end
|
50
50
|
end
|
@@ -3,11 +3,11 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSubOwner::Purge do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:purge, 'http://jabber.org/protocol/pubsub#owner').
|
6
|
+
Blather::XMPPNode.class_from_registration(:purge, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner::Purge
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.
|
10
|
+
Blather::XMPPNode.parse(<<-NODE).should be_instance_of Blather::Stanza::PubSubOwner::Purge
|
11
11
|
<iq type='set'
|
12
12
|
from='hamlet@denmark.lit/elsinore'
|
13
13
|
to='pubsub.shakespeare.lit'
|
@@ -21,30 +21,30 @@ describe Blather::Stanza::PubSubOwner::Purge do
|
|
21
21
|
|
22
22
|
it 'ensures an purge node is present on create' do
|
23
23
|
purge = Blather::Stanza::PubSubOwner::Purge.new
|
24
|
-
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
24
|
+
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'ensures an purge node exists when calling #purge_node' do
|
28
28
|
purge = Blather::Stanza::PubSubOwner::Purge.new
|
29
29
|
purge.pubsub.remove_children :purge
|
30
|
-
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
30
|
+
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_empty
|
31
31
|
|
32
|
-
purge.purge_node.
|
33
|
-
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
32
|
+
purge.purge_node.should_not be_nil
|
33
|
+
purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'defaults to a set node' do
|
37
37
|
purge = Blather::Stanza::PubSubOwner::Purge.new
|
38
|
-
purge.type.
|
38
|
+
purge.type.should == :set
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'sets the host if requested' do
|
42
42
|
purge = Blather::Stanza::PubSubOwner::Purge.new :set, 'pubsub.jabber.local'
|
43
|
-
purge.to.
|
43
|
+
purge.to.should == Blather::JID.new('pubsub.jabber.local')
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'sets the node' do
|
47
47
|
purge = Blather::Stanza::PubSubOwner::Purge.new :set, 'host', 'node-name'
|
48
|
-
purge.node.
|
48
|
+
purge.node.should == 'node-name'
|
49
49
|
end
|
50
50
|
end
|
@@ -3,25 +3,25 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSubOwner do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub#owner').
|
6
|
+
Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'ensures a pubusb node is present on create' do
|
10
10
|
pubsub = Blather::Stanza::PubSubOwner.new
|
11
|
-
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
11
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'ensures a pubsub node exists when calling #pubsub' do
|
15
15
|
pubsub = Blather::Stanza::PubSubOwner.new
|
16
16
|
pubsub.remove_children :pubsub
|
17
|
-
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
17
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_nil
|
18
18
|
|
19
|
-
pubsub.pubsub.
|
20
|
-
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
19
|
+
pubsub.pubsub.should_not be_nil
|
20
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_nil
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'sets the host if requested' do
|
24
24
|
aff = Blather::Stanza::PubSubOwner.new :get, 'pubsub.jabber.local'
|
25
|
-
aff.to.
|
25
|
+
aff.to.should == Blather::JID.new('pubsub.jabber.local')
|
26
26
|
end
|
27
27
|
end
|
@@ -3,31 +3,31 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub').
|
6
|
+
Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'ensures a pubusb node is present on create' do
|
10
10
|
pubsub = Blather::Stanza::PubSub.new
|
11
|
-
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).
|
11
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'ensures a pubsub node exists when calling #pubsub' do
|
15
15
|
pubsub = Blather::Stanza::PubSub.new
|
16
16
|
pubsub.remove_children :pubsub
|
17
|
-
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).
|
17
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should be_nil
|
18
18
|
|
19
|
-
pubsub.pubsub.
|
20
|
-
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).
|
19
|
+
pubsub.pubsub.should_not be_nil
|
20
|
+
pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'sets the host if requested' do
|
24
24
|
aff = Blather::Stanza::PubSub.new :get, 'pubsub.jabber.local'
|
25
|
-
aff.to.
|
25
|
+
aff.to.should == Blather::JID.new('pubsub.jabber.local')
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'ensures newly inherited items are PubSubItem objects' do
|
29
|
-
pubsub = Blather::XMPPNode.
|
30
|
-
pubsub.items.map { |i| i.class }.uniq.
|
29
|
+
pubsub = Blather::XMPPNode.parse(items_all_nodes_xml)
|
30
|
+
pubsub.items.map { |i| i.class }.uniq.should == [Blather::Stanza::PubSub::PubSubItem]
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,34 +35,34 @@ describe Blather::Stanza::PubSub::PubSubItem do
|
|
35
35
|
it 'can be initialized with just an ID' do
|
36
36
|
id = 'foobarbaz'
|
37
37
|
item = Blather::Stanza::PubSub::Items::PubSubItem.new id
|
38
|
-
item.id.
|
38
|
+
item.id.should == id
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'can be initialized with a payload' do
|
42
42
|
payload = 'foobarbaz'
|
43
43
|
item = Blather::Stanza::PubSub::Items::PubSubItem.new 'foo', payload
|
44
|
-
item.payload.
|
44
|
+
item.payload.should == payload
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'allows the payload to be set' do
|
48
48
|
item = Blather::Stanza::PubSub::Items::PubSubItem.new
|
49
|
-
item.payload.
|
49
|
+
item.payload.should be_nil
|
50
50
|
item.payload = 'testing'
|
51
|
-
item.payload.
|
52
|
-
item.content.
|
51
|
+
item.payload.should == 'testing'
|
52
|
+
item.content.should == 'testing'
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'allows the payload to be unset' do
|
56
56
|
payload = 'foobarbaz'
|
57
57
|
item = Blather::Stanza::PubSub::Items::PubSubItem.new 'foo', payload
|
58
|
-
item.payload.
|
58
|
+
item.payload.should == payload
|
59
59
|
item.payload = nil
|
60
|
-
item.payload.
|
60
|
+
item.payload.should be_nil
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'makes payloads readable as string' do
|
64
64
|
payload = Blather::XMPPNode.new 'foo'
|
65
65
|
item = Blather::Stanza::PubSub::Items::PubSubItem.new 'bar', payload
|
66
|
-
item.payload.
|
66
|
+
item.payload.should == payload.to_s
|
67
67
|
end
|
68
68
|
end
|
@@ -32,60 +32,60 @@ describe Blather::Stanza::X do
|
|
32
32
|
|
33
33
|
it 'can be created from an XML string' do
|
34
34
|
x = Blather::Stanza::X.new parse_stanza(x_xml).root
|
35
|
-
x.type.
|
36
|
-
x.
|
35
|
+
x.type.should == :form
|
36
|
+
x.should be_instance_of Blather::Stanza::X
|
37
37
|
end
|
38
38
|
|
39
39
|
[:cancel, :form, :result, :submit].each do |type|
|
40
40
|
it "type can be set as \"#{type}\"" do
|
41
41
|
x = Blather::Stanza::X.new type
|
42
|
-
x.type.
|
42
|
+
x.type.should == type
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'is constructed properly' do
|
47
47
|
n = Blather::Stanza::X.new :form
|
48
|
-
n.find("/ns:x[@type='form']", :ns => Blather::Stanza::X.registered_ns).
|
48
|
+
n.find("/ns:x[@type='form']", :ns => Blather::Stanza::X.registered_ns).should_not be_empty
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'has an action attribute' do
|
52
52
|
n = Blather::Stanza::X.new :form
|
53
|
-
n.type.
|
53
|
+
n.type.should == :form
|
54
54
|
n.type = :submit
|
55
|
-
n.type.
|
55
|
+
n.type.should == :submit
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'has a title attribute' do
|
59
59
|
n = Blather::Stanza::X.new :form
|
60
|
-
n.title.
|
60
|
+
n.title.should == nil
|
61
61
|
n.title = "Hello World!"
|
62
|
-
n.title.
|
62
|
+
n.title.should == "Hello World!"
|
63
63
|
n.title = "goodbye"
|
64
|
-
n.title.
|
64
|
+
n.title.should == "goodbye"
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'has an instructions attribute' do
|
68
68
|
n = Blather::Stanza::X.new :form
|
69
|
-
n.instructions.
|
69
|
+
n.instructions.should == nil
|
70
70
|
n.instructions = "Please fill in this form"
|
71
|
-
n.instructions.
|
71
|
+
n.instructions.should == "Please fill in this form"
|
72
72
|
n.instructions = "goodbye"
|
73
|
-
n.instructions.
|
73
|
+
n.instructions.should == "goodbye"
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'inherits a list of fields' do
|
77
77
|
n = Blather::Stanza::Iq::Command.new
|
78
78
|
n.command << parse_stanza(x_xml).root
|
79
79
|
r = Blather::Stanza::X.new.inherit n.form
|
80
|
-
r.fields.size.
|
81
|
-
r.fields.map { |f| f.class }.uniq.
|
80
|
+
r.fields.size.should == 4
|
81
|
+
r.fields.map { |f| f.class }.uniq.should == [Blather::Stanza::X::Field]
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'returns a field object for a particular var' do
|
85
85
|
x = Blather::Stanza::X.new parse_stanza(x_xml).root
|
86
86
|
f = x.field 'field-name4'
|
87
|
-
f.
|
88
|
-
f.value.
|
87
|
+
f.should be_instance_of Blather::Stanza::X::Field
|
88
|
+
f.value.should == 'field-value4'
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'takes a list of hashes for fields' do
|
@@ -98,8 +98,8 @@ describe Blather::Stanza::X do
|
|
98
98
|
Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
|
99
99
|
|
100
100
|
di = Blather::Stanza::X.new nil, fields
|
101
|
-
di.fields.size.
|
102
|
-
di.fields.each { |f| control.include?(f).
|
101
|
+
di.fields.size.should == 2
|
102
|
+
di.fields.each { |f| control.include?(f).should == true }
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'takes a list of Field objects as fields' do
|
@@ -107,8 +107,8 @@ describe Blather::Stanza::X do
|
|
107
107
|
Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
|
108
108
|
|
109
109
|
di = Blather::Stanza::X.new nil, control
|
110
|
-
di.fields.size.
|
111
|
-
di.fields.each { |f| control.include?(f).
|
110
|
+
di.fields.size.should == 2
|
111
|
+
di.fields.each { |f| control.include?(f).should == true }
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'takes a mix of hashes and field objects as fields' do
|
@@ -121,17 +121,17 @@ describe Blather::Stanza::X do
|
|
121
121
|
Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
|
122
122
|
|
123
123
|
di = Blather::Stanza::X.new nil, fields
|
124
|
-
di.fields.size.
|
125
|
-
di.fields.each { |f| control.include?(f).
|
124
|
+
di.fields.size.should == 2
|
125
|
+
di.fields.each { |f| control.include?(f).should == true }
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'allows adding of fields' do
|
129
129
|
di = Blather::Stanza::X.new nil
|
130
|
-
di.fields.size.
|
130
|
+
di.fields.size.should == 0
|
131
131
|
di.fields = [{:label => 'label', :type => 'text-single', :var => 'var', :required => true}]
|
132
|
-
di.fields.size.
|
132
|
+
di.fields.size.should == 1
|
133
133
|
di.fields += [Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
|
134
|
-
di.fields.size.
|
134
|
+
di.fields.size.should == 2
|
135
135
|
end
|
136
136
|
|
137
137
|
end
|
@@ -140,73 +140,73 @@ describe Blather::Stanza::X::Field do
|
|
140
140
|
it 'will auto-inherit nodes' do
|
141
141
|
n = parse_stanza "<field type='text-single' var='music' label='Music from the time of Shakespeare' />"
|
142
142
|
i = Blather::Stanza::X::Field.new n.root
|
143
|
-
i.type.
|
144
|
-
i.var.
|
145
|
-
i.label.
|
143
|
+
i.type.should == 'text-single'
|
144
|
+
i.var.should == 'music'
|
145
|
+
i.label.should == 'Music from the time of Shakespeare'
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'has a type attribute' do
|
149
149
|
n = Blather::Stanza::X::Field.new 'var', 'text-single'
|
150
|
-
n.type.
|
150
|
+
n.type.should == 'text-single'
|
151
151
|
n.type = 'hidden'
|
152
|
-
n.type.
|
152
|
+
n.type.should == 'hidden'
|
153
153
|
end
|
154
154
|
|
155
155
|
it 'has a var attribute' do
|
156
156
|
n = Blather::Stanza::X::Field.new 'name', 'text-single'
|
157
|
-
n.var.
|
157
|
+
n.var.should == 'name'
|
158
158
|
n.var = 'email'
|
159
|
-
n.var.
|
159
|
+
n.var.should == 'email'
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'has a label attribute' do
|
163
163
|
n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
|
164
|
-
n.label.
|
164
|
+
n.label.should == 'Music from the time of Shakespeare'
|
165
165
|
n.label = 'Books by and about Shakespeare'
|
166
|
-
n.label.
|
166
|
+
n.label.should == 'Books by and about Shakespeare'
|
167
167
|
end
|
168
168
|
|
169
169
|
it 'has a desc attribute' do
|
170
170
|
n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
|
171
|
-
n.desc.
|
171
|
+
n.desc.should == nil
|
172
172
|
n.desc = 'Books by and about Shakespeare'
|
173
|
-
n.desc.
|
173
|
+
n.desc.should == 'Books by and about Shakespeare'
|
174
174
|
n.desc = 'goodbye'
|
175
|
-
n.desc.
|
175
|
+
n.desc.should == 'goodbye'
|
176
176
|
end
|
177
177
|
|
178
178
|
it 'has a required? attribute' do
|
179
179
|
n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
|
180
|
-
n.required?.
|
180
|
+
n.required?.should == false
|
181
181
|
n.required = true
|
182
|
-
n.required?.
|
182
|
+
n.required?.should == true
|
183
183
|
n.required = false
|
184
|
-
n.required?.
|
184
|
+
n.required?.should == false
|
185
185
|
end
|
186
186
|
|
187
187
|
it 'has a value attribute' do
|
188
188
|
n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
|
189
|
-
n.value.
|
189
|
+
n.value.should == nil
|
190
190
|
n.value = 'book1'
|
191
|
-
n.value.
|
191
|
+
n.value.should == 'book1'
|
192
192
|
n.value = 'book2'
|
193
|
-
n.value.
|
193
|
+
n.value.should == 'book2'
|
194
194
|
end
|
195
195
|
|
196
196
|
# Option child elements
|
197
197
|
it 'allows adding of options' do
|
198
198
|
di = Blather::Stanza::X::Field.new nil
|
199
|
-
di.options.size.
|
199
|
+
di.options.size.should == 0
|
200
200
|
di.options += [{:label => 'Person', :value => 'person'}]
|
201
|
-
di.options.size.
|
201
|
+
di.options.size.should == 1
|
202
202
|
di.options += [Blather::Stanza::X::Field::Option.new(*%w[person1 Person1])]
|
203
|
-
di.options.size.
|
203
|
+
di.options.size.should == 2
|
204
204
|
end
|
205
205
|
|
206
206
|
it 'can determine equality' do
|
207
207
|
a = Blather::Stanza::X::Field.new('subject', 'text-single')
|
208
|
-
a.
|
209
|
-
a.
|
208
|
+
a.should == Blather::Stanza::X::Field.new('subject', 'text-single')
|
209
|
+
a.should_not equal Blather::Stanza::X::Field.new('subject1', 'text-single')
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
@@ -214,17 +214,17 @@ describe Blather::Stanza::X::Field::Option do
|
|
214
214
|
|
215
215
|
it 'has a value attribute' do
|
216
216
|
n = Blather::Stanza::X::Field::Option.new 'person1', 'Person 1'
|
217
|
-
n.value.
|
217
|
+
n.value.should == 'person1'
|
218
218
|
n.value = 'book1'
|
219
|
-
n.value.
|
219
|
+
n.value.should == 'book1'
|
220
220
|
end
|
221
221
|
|
222
222
|
it 'has a label attribute' do
|
223
223
|
n = Blather::Stanza::X::Field::Option.new 'person1', 'Person 1'
|
224
|
-
n.label.
|
224
|
+
n.label.should == 'Person 1'
|
225
225
|
n.label = 'Book 1'
|
226
|
-
n.label.
|
226
|
+
n.label.should == 'Book 1'
|
227
227
|
n.label = 'Book 2'
|
228
|
-
n.label.
|
228
|
+
n.label.should == 'Book 2'
|
229
229
|
end
|
230
230
|
end
|