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