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
@@ -23,31 +23,31 @@ end
|
|
23
23
|
|
24
24
|
describe Blather::Stanza::Iq::DiscoItems do
|
25
25
|
it 'registers itself' do
|
26
|
-
Blather::XMPPNode.class_from_registration(:query, 'http://jabber.org/protocol/disco#items').
|
26
|
+
Blather::XMPPNode.class_from_registration(:query, 'http://jabber.org/protocol/disco#items').should == Blather::Stanza::Iq::DiscoItems
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'must be importable' do
|
30
|
-
Blather::XMPPNode.
|
30
|
+
Blather::XMPPNode.parse(disco_items_xml).should be_instance_of Blather::Stanza::Iq::DiscoItems
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'is constructed properly' do
|
34
34
|
n = Blather::Stanza::Iq::DiscoItems.new :get, '/path/to/node'
|
35
35
|
n.to = 'to@jid.com'
|
36
|
-
n.find("/iq[@to='to@jid.com' and @type='get' and @id='#{n.id}']/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::Iq::DiscoItems.registered_ns).
|
36
|
+
n.find("/iq[@to='to@jid.com' and @type='get' and @id='#{n.id}']/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::Iq::DiscoItems.registered_ns).should_not be_empty
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'has a node attribute' do
|
40
40
|
n = Blather::Stanza::Iq::DiscoItems.new nil, 'music', []
|
41
|
-
n.node.
|
41
|
+
n.node.should == 'music'
|
42
42
|
n.node = :foo
|
43
|
-
n.node.
|
43
|
+
n.node.should == 'foo'
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'inherits a list of identities' do
|
47
47
|
n = parse_stanza disco_items_xml
|
48
48
|
r = Blather::Stanza::Iq::DiscoItems.new.inherit n.root
|
49
|
-
r.items.size.
|
50
|
-
r.items.map { |i| i.class }.uniq.
|
49
|
+
r.items.size.should == 3
|
50
|
+
r.items.map { |i| i.class }.uniq.should == [Blather::Stanza::Iq::DiscoItems::Item]
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'takes a list of hashes for items' do
|
@@ -60,8 +60,8 @@ describe Blather::Stanza::Iq::DiscoItems do
|
|
60
60
|
Blather::Stanza::Iq::DiscoItems::Item.new(*%w[baz@foo/bar node1 name1])]
|
61
61
|
|
62
62
|
di = Blather::Stanza::Iq::DiscoItems.new nil, nil, items
|
63
|
-
di.items.size.
|
64
|
-
di.items.each { |i| control.include?(i).
|
63
|
+
di.items.size.should == 2
|
64
|
+
di.items.each { |i| control.include?(i).should == true }
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'takes a list of Item objects as items' do
|
@@ -69,24 +69,24 @@ describe Blather::Stanza::Iq::DiscoItems do
|
|
69
69
|
Blather::Stanza::Iq::DiscoItems::Item.new(*%w[baz@foo/bar node1 name1])]
|
70
70
|
|
71
71
|
di = Blather::Stanza::Iq::DiscoItems.new nil, nil, control
|
72
|
-
di.items.size.
|
73
|
-
di.items.each { |i| control.include?(i).
|
72
|
+
di.items.size.should == 2
|
73
|
+
di.items.each { |i| control.include?(i).should == true }
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'takes a single hash as identity' do
|
77
77
|
control = [Blather::Stanza::Iq::DiscoItems::Item.new(*%w[foo@bar/baz node name])]
|
78
78
|
|
79
79
|
di = Blather::Stanza::Iq::DiscoItems.new nil, nil, {:jid => 'foo@bar/baz', :node => 'node', :name => 'name'}
|
80
|
-
di.items.size.
|
81
|
-
di.items.each { |i| control.include?(i).
|
80
|
+
di.items.size.should == 1
|
81
|
+
di.items.each { |i| control.include?(i).should == true }
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'takes a single identity object as identity' do
|
85
85
|
control = [Blather::Stanza::Iq::DiscoItems::Item.new(*%w[foo@bar/baz node name])]
|
86
86
|
|
87
87
|
di = Blather::Stanza::Iq::DiscoItems.new nil, nil, control.first
|
88
|
-
di.items.size.
|
89
|
-
di.items.each { |i| control.include?(i).
|
88
|
+
di.items.size.should == 1
|
89
|
+
di.items.each { |i| control.include?(i).should == true }
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'takes a mix of hashes and identity objects as items' do
|
@@ -99,19 +99,19 @@ describe Blather::Stanza::Iq::DiscoItems do
|
|
99
99
|
Blather::Stanza::Iq::DiscoItems::Item.new(*%w[baz@foo/bar node1 name1])]
|
100
100
|
|
101
101
|
di = Blather::Stanza::Iq::DiscoItems.new nil, nil, items
|
102
|
-
di.items.size.
|
103
|
-
di.items.each { |i| control.include?(i).
|
102
|
+
di.items.size.should == 2
|
103
|
+
di.items.each { |i| control.include?(i).should == true }
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'allows adding of items' do
|
107
107
|
di = Blather::Stanza::Iq::DiscoItems.new
|
108
|
-
di.items.size.
|
108
|
+
di.items.size.should == 0
|
109
109
|
di.items = [{:jid => 'foo@bar/baz', :node => 'node', :name => 'name'}]
|
110
|
-
di.items.size.
|
110
|
+
di.items.size.should == 1
|
111
111
|
di.items += [Blather::Stanza::Iq::DiscoItems::Item.new(*%w[foo@bar/baz node name])]
|
112
|
-
di.items.size.
|
112
|
+
di.items.size.should == 2
|
113
113
|
di.items = nil
|
114
|
-
di.items.size.
|
114
|
+
di.items.size.should == 0
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -119,36 +119,36 @@ describe Blather::Stanza::Iq::DiscoItems::Item do
|
|
119
119
|
it 'will auto-inherit nodes' do
|
120
120
|
n = parse_stanza "<item jid='foo@bar/baz' node='music' name='Music from the time of Shakespeare' />"
|
121
121
|
i = Blather::Stanza::Iq::DiscoItems::Item.new n.root
|
122
|
-
i.jid.
|
123
|
-
i.node.
|
124
|
-
i.name.
|
122
|
+
i.jid.should == Blather::JID.new('foo@bar/baz')
|
123
|
+
i.node.should == 'music'
|
124
|
+
i.name.should == 'Music from the time of Shakespeare'
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'has a jid attribute' do
|
128
128
|
n = Blather::Stanza::Iq::DiscoItems::Item.new 'foo@bar/baz'
|
129
|
-
n.jid.
|
130
|
-
n.jid.
|
129
|
+
n.jid.should be_kind_of Blather::JID
|
130
|
+
n.jid.should == Blather::JID.new('foo@bar/baz')
|
131
131
|
n.jid = 'baz@foo/bar'
|
132
|
-
n.jid.
|
132
|
+
n.jid.should == Blather::JID.new('baz@foo/bar')
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'has a node attribute' do
|
136
136
|
n = Blather::Stanza::Iq::DiscoItems::Item.new 'foo@bar/baz', 'music'
|
137
|
-
n.node.
|
137
|
+
n.node.should == 'music'
|
138
138
|
n.node = 'book'
|
139
|
-
n.node.
|
139
|
+
n.node.should == 'book'
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'has a name attribute' do
|
143
143
|
n = Blather::Stanza::Iq::DiscoItems::Item.new 'foo@bar/baz', nil, 'Music from the time of Shakespeare'
|
144
|
-
n.name.
|
144
|
+
n.name.should == 'Music from the time of Shakespeare'
|
145
145
|
n.name = 'Books by and about Shakespeare'
|
146
|
-
n.name.
|
146
|
+
n.name.should == 'Books by and about Shakespeare'
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'can determine equality' do
|
150
150
|
a = Blather::Stanza::Iq::DiscoItems::Item.new('foo@bar/baz')
|
151
|
-
a.
|
152
|
-
a.
|
151
|
+
a.should == Blather::Stanza::Iq::DiscoItems::Item.new('foo@bar/baz')
|
152
|
+
a.should_not equal Blather::Stanza::Iq::DiscoItems::Item.new('not-foo@bar/baz')
|
153
153
|
end
|
154
154
|
end
|
@@ -19,188 +19,188 @@ end
|
|
19
19
|
|
20
20
|
describe Blather::Stanza::Iq::Command do
|
21
21
|
it 'registers itself' do
|
22
|
-
Blather::XMPPNode.class_from_registration(:command, 'http://jabber.org/protocol/commands').
|
22
|
+
Blather::XMPPNode.class_from_registration(:command, 'http://jabber.org/protocol/commands').should == Blather::Stanza::Iq::Command
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'must be importable' do
|
26
|
-
Blather::XMPPNode.
|
26
|
+
Blather::XMPPNode.parse(command_xml).should be_instance_of Blather::Stanza::Iq::Command
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'ensures a command node is present on create' do
|
30
30
|
c = Blather::Stanza::Iq::Command.new
|
31
|
-
c.xpath('xmlns:command', :xmlns => Blather::Stanza::Iq::Command.registered_ns).
|
31
|
+
c.xpath('xmlns:command', :xmlns => Blather::Stanza::Iq::Command.registered_ns).should_not be_empty
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'ensures a command node exists when calling #command' do
|
35
35
|
c = Blather::Stanza::Iq::Command.new
|
36
36
|
c.remove_children :command
|
37
|
-
c.xpath('ns:command', :ns => Blather::Stanza::Iq::Command.registered_ns).
|
37
|
+
c.xpath('ns:command', :ns => Blather::Stanza::Iq::Command.registered_ns).should be_empty
|
38
38
|
|
39
|
-
c.command.
|
40
|
-
c.xpath('ns:command', :ns => Blather::Stanza::Iq::Command.registered_ns).
|
39
|
+
c.command.should_not be_nil
|
40
|
+
c.xpath('ns:command', :ns => Blather::Stanza::Iq::Command.registered_ns).should_not be_empty
|
41
41
|
end
|
42
42
|
|
43
43
|
Blather::Stanza::Iq::Command::VALID_ACTIONS.each do |valid_action|
|
44
44
|
it "provides a helper (#{valid_action}?) for action #{valid_action}" do
|
45
|
-
Blather::Stanza::Iq::Command.new.
|
45
|
+
Blather::Stanza::Iq::Command.new.should respond_to :"#{valid_action}?"
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
Blather::Stanza::Iq::Command::VALID_STATUS.each do |valid_status|
|
50
50
|
it "provides a helper (#{valid_status}?) for status #{valid_status}" do
|
51
|
-
Blather::Stanza::Iq::Command.new.
|
51
|
+
Blather::Stanza::Iq::Command.new.should respond_to :"#{valid_status}?"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
Blather::Stanza::Iq::Command::VALID_NOTE_TYPES.each do |valid_note_type|
|
56
56
|
it "provides a helper (#{valid_note_type}?) for note_type #{valid_note_type}" do
|
57
|
-
Blather::Stanza::Iq::Command.new.
|
57
|
+
Blather::Stanza::Iq::Command.new.should respond_to :"#{valid_note_type}?"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
[:cancel, :execute, :complete, :next, :prev].each do |action|
|
62
62
|
it "action can be set as \"#{action}\"" do
|
63
63
|
c = Blather::Stanza::Iq::Command.new nil, nil, action
|
64
|
-
c.action.
|
64
|
+
c.action.should == action
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
[:get, :set, :result, :error].each do |type|
|
69
69
|
it "can be set as \"#{type}\"" do
|
70
70
|
c = Blather::Stanza::Iq::Command.new type
|
71
|
-
c.type.
|
71
|
+
c.type.should == type
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'sets type to "result" on reply' do
|
76
76
|
c = Blather::Stanza::Iq::Command.new
|
77
|
-
c.type.
|
78
|
-
reply = c.reply.type.
|
77
|
+
c.type.should == :set
|
78
|
+
reply = c.reply.type.should == :result
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'sets type to "result" on reply!' do
|
82
82
|
c = Blather::Stanza::Iq::Command.new
|
83
|
-
c.type.
|
83
|
+
c.type.should == :set
|
84
84
|
c.reply!
|
85
|
-
c.type.
|
85
|
+
c.type.should == :result
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'removes action on reply' do
|
89
|
-
c = Blather::XMPPNode.
|
90
|
-
c.action.
|
91
|
-
c.reply.action.
|
89
|
+
c = Blather::XMPPNode.parse command_xml
|
90
|
+
c.action.should == :execute
|
91
|
+
c.reply.action.should == nil
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'removes action on reply!' do
|
95
|
-
c = Blather::XMPPNode.
|
96
|
-
c.action.
|
95
|
+
c = Blather::XMPPNode.parse command_xml
|
96
|
+
c.action.should == :execute
|
97
97
|
c.reply!
|
98
|
-
c.action.
|
98
|
+
c.action.should == nil
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'can be registered under a namespace' do
|
102
102
|
class CommandNs < Blather::Stanza::Iq::Command; register :command_ns, nil, 'command:ns'; end
|
103
|
-
Blather::XMPPNode.class_from_registration(:command, 'command:ns').
|
103
|
+
Blather::XMPPNode.class_from_registration(:command, 'command:ns').should == CommandNs
|
104
104
|
c_ns = CommandNs.new
|
105
|
-
c_ns.xpath('command').
|
106
|
-
c_ns.xpath('ns:command', :ns => 'command:ns').size.
|
105
|
+
c_ns.xpath('command').should be_empty
|
106
|
+
c_ns.xpath('ns:command', :ns => 'command:ns').size.should == 1
|
107
107
|
|
108
108
|
c_ns.command
|
109
109
|
c_ns.command
|
110
|
-
c_ns.xpath('ns:command', :ns => 'command:ns').size.
|
110
|
+
c_ns.xpath('ns:command', :ns => 'command:ns').size.should == 1
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'is constructed properly' do
|
114
114
|
n = Blather::Stanza::Iq::Command.new :set, "node", :execute
|
115
115
|
n.to = 'to@jid.com'
|
116
|
-
n.find("/iq[@to='to@jid.com' and @type='set' and @id='#{n.id}']/ns:command[@node='node' and @action='execute']", :ns => Blather::Stanza::Iq::Command.registered_ns).
|
116
|
+
n.find("/iq[@to='to@jid.com' and @type='set' and @id='#{n.id}']/ns:command[@node='node' and @action='execute']", :ns => Blather::Stanza::Iq::Command.registered_ns).should_not be_empty
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'has an action attribute' do
|
120
120
|
n = Blather::Stanza::Iq::Command.new
|
121
|
-
n.action.
|
121
|
+
n.action.should == :execute
|
122
122
|
n.action = :cancel
|
123
|
-
n.action.
|
123
|
+
n.action.should == :cancel
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'must default action to :execute on import' do
|
127
|
-
n = Blather::XMPPNode.
|
128
|
-
n.action.
|
127
|
+
n = Blather::XMPPNode.parse(command_xml)
|
128
|
+
n.action.should == :execute
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'has a status attribute' do
|
132
132
|
n = Blather::Stanza::Iq::Command.new
|
133
|
-
n.status.
|
133
|
+
n.status.should == :executing
|
134
134
|
n.status = :completed
|
135
|
-
n.status.
|
135
|
+
n.status.should == :completed
|
136
136
|
end
|
137
137
|
|
138
138
|
it 'has a sessionid attribute' do
|
139
139
|
n = Blather::Stanza::Iq::Command.new
|
140
|
-
n.sessionid.
|
140
|
+
n.sessionid.should == nil
|
141
141
|
n.sessionid = "somerandomstring"
|
142
|
-
n.sessionid.
|
142
|
+
n.sessionid.should == Digest::SHA1.hexdigest("somerandomstring")
|
143
143
|
end
|
144
144
|
|
145
145
|
it 'has a sessionid? attribute' do
|
146
146
|
n = Blather::Stanza::Iq::Command.new
|
147
|
-
n.sessionid?.
|
147
|
+
n.sessionid?.should == false
|
148
148
|
n.new_sessionid!
|
149
|
-
n.sessionid?.
|
149
|
+
n.sessionid?.should == true
|
150
150
|
end
|
151
151
|
|
152
152
|
it 'has an allowed_actions attribute' do
|
153
|
-
n = Blather::XMPPNode.
|
154
|
-
n.allowed_actions.
|
153
|
+
n = Blather::XMPPNode.parse command_xml
|
154
|
+
n.allowed_actions.should == [:execute]
|
155
155
|
n.allowed_actions = [:next, :prev]
|
156
|
-
(n.allowed_actions - [:next, :prev, :execute]).
|
156
|
+
(n.allowed_actions - [:next, :prev, :execute]).should be_empty
|
157
157
|
n.remove_allowed_actions!
|
158
|
-
n.allowed_actions.
|
158
|
+
n.allowed_actions.should == [:execute]
|
159
159
|
n.allowed_actions += [:next]
|
160
|
-
(n.allowed_actions - [:next, :execute]).
|
160
|
+
(n.allowed_actions - [:next, :execute]).should be_empty
|
161
161
|
|
162
162
|
r = Blather::Stanza::Iq::Command.new
|
163
|
-
r.allowed_actions.
|
163
|
+
r.allowed_actions.should == [:execute]
|
164
164
|
r.allowed_actions += [:prev]
|
165
|
-
(r.allowed_actions - [:prev, :execute]).
|
165
|
+
(r.allowed_actions - [:prev, :execute]).should be_empty
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'has a primary_allowed_action attribute' do
|
169
|
-
n = Blather::XMPPNode.
|
170
|
-
n.primary_allowed_action.
|
169
|
+
n = Blather::XMPPNode.parse command_xml
|
170
|
+
n.primary_allowed_action.should == :execute
|
171
171
|
n.primary_allowed_action = :next
|
172
|
-
n.primary_allowed_action.
|
172
|
+
n.primary_allowed_action.should == :next
|
173
173
|
end
|
174
174
|
|
175
175
|
it 'has a note_type attribute' do
|
176
176
|
n = Blather::Stanza::Iq::Command.new
|
177
|
-
n.note_type.
|
177
|
+
n.note_type.should == nil
|
178
178
|
n.note_type = :info
|
179
|
-
n.note_type.
|
179
|
+
n.note_type.should == :info
|
180
180
|
end
|
181
181
|
|
182
182
|
it 'has a note_text attribute' do
|
183
183
|
n = Blather::Stanza::Iq::Command.new
|
184
|
-
n.note_text.
|
184
|
+
n.note_text.should == nil
|
185
185
|
n.note_text = "Some text"
|
186
|
-
n.note_text.
|
186
|
+
n.note_text.should == "Some text"
|
187
187
|
end
|
188
188
|
|
189
189
|
it 'makes a form child available' do
|
190
|
-
n = Blather::XMPPNode.
|
191
|
-
n.form.fields.size.
|
192
|
-
n.form.fields.map { |f| f.class }.uniq.
|
193
|
-
n.form.
|
190
|
+
n = Blather::XMPPNode.parse(command_xml)
|
191
|
+
n.form.fields.size.should == 1
|
192
|
+
n.form.fields.map { |f| f.class }.uniq.should == [Blather::Stanza::X::Field]
|
193
|
+
n.form.should be_instance_of Blather::Stanza::X
|
194
194
|
|
195
195
|
r = Blather::Stanza::Iq::Command.new
|
196
196
|
r.form.type = :form
|
197
|
-
r.form.type.
|
197
|
+
r.form.type.should == :form
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'ensures the form child is a child of command' do
|
201
201
|
r = Blather::Stanza::Iq::Command.new
|
202
202
|
r.form
|
203
|
-
r.command.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).
|
204
|
-
r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).
|
203
|
+
r.command.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).should_not be_empty
|
204
|
+
r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).should be_empty
|
205
205
|
end
|
206
206
|
end
|
@@ -44,93 +44,81 @@ end
|
|
44
44
|
|
45
45
|
describe Blather::Stanza::Iq::Ibb::Open do
|
46
46
|
it 'registers itself' do
|
47
|
-
Blather::XMPPNode.class_from_registration(:open, 'http://jabber.org/protocol/ibb').
|
47
|
+
Blather::XMPPNode.class_from_registration(:open, 'http://jabber.org/protocol/ibb').should == Blather::Stanza::Iq::Ibb::Open
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'can be imported' do
|
51
|
-
|
52
|
-
node
|
53
|
-
node.must_be_instance_of Blather::Stanza::Iq::Ibb::Open
|
51
|
+
node = Blather::XMPPNode.parse ibb_open_xml
|
52
|
+
node.should be_instance_of Blather::Stanza::Iq::Ibb::Open
|
54
53
|
end
|
55
54
|
|
56
55
|
it 'has open node' do
|
57
|
-
|
58
|
-
node
|
59
|
-
node.open.must_be_kind_of Nokogiri::XML::Element
|
56
|
+
node = Blather::XMPPNode.parse ibb_open_xml
|
57
|
+
node.open.should be_kind_of Nokogiri::XML::Element
|
60
58
|
end
|
61
59
|
|
62
60
|
it 'can get sid' do
|
63
|
-
|
64
|
-
node
|
65
|
-
node.sid.must_equal 'i781hf64'
|
61
|
+
node = Blather::XMPPNode.parse ibb_open_xml
|
62
|
+
node.sid.should == 'i781hf64'
|
66
63
|
end
|
67
64
|
|
68
65
|
it 'deleted open node on reply' do
|
69
|
-
|
70
|
-
node = Blather::XMPPNode.import(doc.root)
|
66
|
+
node = Blather::XMPPNode.parse ibb_open_xml
|
71
67
|
reply = node.reply
|
72
|
-
reply.open.
|
68
|
+
reply.open.should be_nil
|
73
69
|
end
|
74
70
|
end
|
75
71
|
|
76
72
|
describe Blather::Stanza::Iq::Ibb::Data do
|
77
73
|
it 'registers itself' do
|
78
|
-
Blather::XMPPNode.class_from_registration(:data, 'http://jabber.org/protocol/ibb').
|
74
|
+
Blather::XMPPNode.class_from_registration(:data, 'http://jabber.org/protocol/ibb').should == Blather::Stanza::Iq::Ibb::Data
|
79
75
|
end
|
80
76
|
|
81
77
|
it 'can be imported' do
|
82
|
-
|
83
|
-
node
|
84
|
-
node.must_be_instance_of Blather::Stanza::Iq::Ibb::Data
|
78
|
+
node = Blather::XMPPNode.parse ibb_data_xml
|
79
|
+
node.should be_instance_of Blather::Stanza::Iq::Ibb::Data
|
85
80
|
end
|
86
81
|
|
87
82
|
it 'has data node' do
|
88
|
-
|
89
|
-
node
|
90
|
-
node.data.must_be_kind_of Nokogiri::XML::Element
|
83
|
+
node = Blather::XMPPNode.parse ibb_data_xml
|
84
|
+
node.data.should be_kind_of Nokogiri::XML::Element
|
91
85
|
end
|
92
86
|
|
93
87
|
it 'can get sid' do
|
94
|
-
|
95
|
-
node
|
96
|
-
node.sid.must_equal 'i781hf64'
|
88
|
+
node = Blather::XMPPNode.parse ibb_data_xml
|
89
|
+
node.sid.should == 'i781hf64'
|
97
90
|
end
|
98
91
|
|
99
92
|
it 'deleted data node on reply' do
|
100
|
-
|
101
|
-
node = Blather::XMPPNode.import(doc.root)
|
93
|
+
node = Blather::XMPPNode.parse ibb_data_xml
|
102
94
|
reply = node.reply
|
103
|
-
reply.data.
|
95
|
+
reply.data.should be_nil
|
104
96
|
end
|
105
97
|
end
|
106
98
|
|
107
99
|
describe Blather::Stanza::Iq::Ibb::Close do
|
108
100
|
it 'registers itself' do
|
109
|
-
Blather::XMPPNode.class_from_registration(:close, 'http://jabber.org/protocol/ibb').
|
101
|
+
Blather::XMPPNode.class_from_registration(:close, 'http://jabber.org/protocol/ibb').should == Blather::Stanza::Iq::Ibb::Close
|
110
102
|
end
|
111
103
|
|
112
104
|
it 'can be imported' do
|
113
|
-
|
114
|
-
node
|
115
|
-
node.must_be_instance_of Blather::Stanza::Iq::Ibb::Close
|
105
|
+
node = Blather::XMPPNode.parse ibb_close_xml
|
106
|
+
node.should be_instance_of Blather::Stanza::Iq::Ibb::Close
|
116
107
|
end
|
117
108
|
|
118
109
|
it 'has close node' do
|
119
|
-
|
120
|
-
node
|
121
|
-
node.close.must_be_kind_of Nokogiri::XML::Element
|
110
|
+
node = Blather::XMPPNode.parse ibb_close_xml
|
111
|
+
node.close.should be_kind_of Nokogiri::XML::Element
|
122
112
|
end
|
123
113
|
|
124
114
|
it 'can get sid' do
|
125
|
-
|
126
|
-
node
|
127
|
-
node.sid.must_equal 'i781hf64'
|
115
|
+
node = Blather::XMPPNode.parse ibb_close_xml
|
116
|
+
node.sid.should == 'i781hf64'
|
128
117
|
end
|
129
118
|
|
130
119
|
it 'deleted close node on reply' do
|
131
|
-
|
132
|
-
node = Blather::XMPPNode.import(doc.root)
|
120
|
+
node = Blather::XMPPNode.parse ibb_close_xml
|
133
121
|
reply = node.reply
|
134
|
-
reply.close.
|
122
|
+
reply.close.should be_nil
|
135
123
|
end
|
136
124
|
end
|