blather 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.rspec +3 -0
  2. data/.travis.yml +1 -8
  3. data/CHANGELOG.md +230 -0
  4. data/Guardfile +4 -4
  5. data/README.md +2 -8
  6. data/Rakefile +14 -27
  7. data/blather.gemspec +8 -18
  8. data/lib/blather.rb +1 -0
  9. data/lib/blather/client/client.rb +8 -0
  10. data/lib/blather/roster.rb +7 -0
  11. data/lib/blather/stanza/iq/roster.rb +1 -1
  12. data/lib/blather/stanza/message/muc_user.rb +2 -0
  13. data/lib/blather/stanza/muc/muc_user_base.rb +4 -3
  14. data/lib/blather/stanza/presence.rb +12 -14
  15. data/lib/blather/stanza/presence/c.rb +58 -62
  16. data/lib/blather/stanza/presence/muc.rb +14 -10
  17. data/lib/blather/stanza/presence/muc_user.rb +47 -36
  18. data/lib/blather/stanza/presence/status.rb +106 -101
  19. data/lib/blather/stanza/presence/subscription.rb +59 -60
  20. data/lib/blather/stream.rb +1 -3
  21. data/lib/blather/stream/features/resource.rb +0 -1
  22. data/lib/blather/version.rb +1 -2
  23. data/lib/blather/xmpp_node.rb +24 -3
  24. data/spec/blather/client/client_spec.rb +64 -64
  25. data/spec/blather/client/dsl/pubsub_spec.rb +127 -127
  26. data/spec/blather/client/dsl_spec.rb +11 -11
  27. data/spec/blather/errors/sasl_error_spec.rb +3 -3
  28. data/spec/blather/errors/stanza_error_spec.rb +26 -26
  29. data/spec/blather/errors/stream_error_spec.rb +22 -22
  30. data/spec/blather/errors_spec.rb +7 -7
  31. data/spec/blather/file_transfer_spec.rb +16 -18
  32. data/spec/blather/jid_spec.rb +29 -29
  33. data/spec/blather/roster_item_spec.rb +18 -18
  34. data/spec/blather/roster_spec.rb +18 -18
  35. data/spec/blather/stanza/discos/disco_info_spec.rb +56 -57
  36. data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
  37. data/spec/blather/stanza/iq/command_spec.rb +57 -57
  38. data/spec/blather/stanza/iq/ibb_spec.rb +27 -39
  39. data/spec/blather/stanza/iq/ping_spec.rb +13 -9
  40. data/spec/blather/stanza/iq/query_spec.rb +16 -16
  41. data/spec/blather/stanza/iq/roster_spec.rb +29 -30
  42. data/spec/blather/stanza/iq/s5b_spec.rb +10 -13
  43. data/spec/blather/stanza/iq/si_spec.rb +20 -23
  44. data/spec/blather/stanza/iq/vcard_spec.rb +22 -25
  45. data/spec/blather/stanza/iq_spec.rb +12 -12
  46. data/spec/blather/stanza/message/muc_user_spec.rb +36 -36
  47. data/spec/blather/stanza/message_spec.rb +56 -56
  48. data/spec/blather/stanza/presence/c_spec.rb +17 -7
  49. data/spec/blather/stanza/presence/muc_spec.rb +8 -8
  50. data/spec/blather/stanza/presence/muc_user_spec.rb +23 -23
  51. data/spec/blather/stanza/presence/status_spec.rb +42 -30
  52. data/spec/blather/stanza/presence/subscription_spec.rb +22 -23
  53. data/spec/blather/stanza/presence_spec.rb +72 -34
  54. data/spec/blather/stanza/pubsub/affiliations_spec.rb +12 -12
  55. data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
  56. data/spec/blather/stanza/pubsub/event_spec.rb +31 -31
  57. data/spec/blather/stanza/pubsub/items_spec.rb +21 -21
  58. data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
  59. data/spec/blather/stanza/pubsub/retract_spec.rb +20 -20
  60. data/spec/blather/stanza/pubsub/subscribe_spec.rb +17 -17
  61. data/spec/blather/stanza/pubsub/subscription_spec.rb +28 -28
  62. data/spec/blather/stanza/pubsub/subscriptions_spec.rb +11 -11
  63. data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +22 -22
  64. data/spec/blather/stanza/pubsub_owner/delete_spec.rb +9 -9
  65. data/spec/blather/stanza/pubsub_owner/purge_spec.rb +9 -9
  66. data/spec/blather/stanza/pubsub_owner_spec.rb +6 -6
  67. data/spec/blather/stanza/pubsub_spec.rb +16 -16
  68. data/spec/blather/stanza/x_spec.rb +53 -53
  69. data/spec/blather/stanza_spec.rb +39 -39
  70. data/spec/blather/stream/client_spec.rb +133 -133
  71. data/spec/blather/stream/component_spec.rb +7 -7
  72. data/spec/blather/stream/parser_spec.rb +24 -24
  73. data/spec/blather/stream/ssl_spec.rb +7 -7
  74. data/spec/blather/xmpp_node_spec.rb +17 -7
  75. data/spec/blather_spec.rb +4 -4
  76. data/spec/spec_helper.rb +6 -54
  77. metadata +53 -68
  78. data/CHANGELOG +0 -220
@@ -12,15 +12,15 @@ describe Blather::DSL::PubSub do
12
12
 
13
13
  it 'raises an error when trying to send a stanza without a host' do
14
14
  @pubsub.host = nil
15
- proc { @pubsub.affiliations }.must_raise RuntimeError
15
+ proc { @pubsub.affiliations }.should raise_error RuntimeError
16
16
  end
17
17
 
18
18
  it 'requests affiliations' do
19
19
  @client.expects(:write_with_handler).with do |n|
20
- n.must_be_instance_of Blather::Stanza::PubSub::Affiliations
21
- n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
22
- n.to.must_equal Blather::JID.new(@host)
23
- n.type.must_equal :get
20
+ n.should be_instance_of Blather::Stanza::PubSub::Affiliations
21
+ n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
22
+ n.to.should == Blather::JID.new(@host)
23
+ n.type.should == :get
24
24
  end
25
25
  @pubsub.affiliations
26
26
  end
@@ -28,20 +28,20 @@ describe Blather::DSL::PubSub do
28
28
  it 'requests affiliations from a specified host' do
29
29
  host = 'another.host'
30
30
  @client.expects(:write_with_handler).with do |n|
31
- n.must_be_instance_of Blather::Stanza::PubSub::Affiliations
32
- n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
33
- n.to.must_equal Blather::JID.new(host)
34
- n.type.must_equal :get
31
+ n.should be_instance_of Blather::Stanza::PubSub::Affiliations
32
+ n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
33
+ n.to.should == Blather::JID.new(host)
34
+ n.type.should == :get
35
35
  end
36
36
  @pubsub.affiliations host
37
37
  end
38
38
 
39
39
  it 'requests subscriptions' do
40
40
  @client.expects(:write_with_handler).with do |n|
41
- n.must_be_instance_of Blather::Stanza::PubSub::Subscriptions
42
- n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
43
- n.to.must_equal Blather::JID.new(@host)
44
- n.type.must_equal :get
41
+ n.should be_instance_of Blather::Stanza::PubSub::Subscriptions
42
+ n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
43
+ n.to.should == Blather::JID.new(@host)
44
+ n.type.should == :get
45
45
  end
46
46
  @pubsub.subscriptions
47
47
  end
@@ -49,20 +49,20 @@ describe Blather::DSL::PubSub do
49
49
  it 'requests subscriptions from a specified host' do
50
50
  host = 'another.host'
51
51
  @client.expects(:write_with_handler).with do |n|
52
- n.must_be_instance_of Blather::Stanza::PubSub::Subscriptions
53
- n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
54
- n.to.must_equal Blather::JID.new(host)
55
- n.type.must_equal :get
52
+ n.should be_instance_of Blather::Stanza::PubSub::Subscriptions
53
+ n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
54
+ n.to.should == Blather::JID.new(host)
55
+ n.type.should == :get
56
56
  end
57
57
  @pubsub.subscriptions host
58
58
  end
59
59
 
60
60
  it 'requests nodes defaulting to "/"' do
61
61
  @client.expects(:write_with_handler).with do |n|
62
- n.must_be_instance_of Blather::Stanza::DiscoItems
63
- n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns).wont_be_empty
64
- n.to.must_equal Blather::JID.new(@host)
65
- n.type.must_equal :get
62
+ n.should be_instance_of Blather::Stanza::DiscoItems
63
+ n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns).should_not be_empty
64
+ n.to.should == Blather::JID.new(@host)
65
+ n.type.should == :get
66
66
  end
67
67
  @pubsub.nodes nil
68
68
  end
@@ -70,210 +70,210 @@ describe Blather::DSL::PubSub do
70
70
  it 'requests nodes from a specified host' do
71
71
  host = 'another.host'
72
72
  @client.expects(:write_with_handler).with do |n|
73
- n.must_be_instance_of Blather::Stanza::DiscoItems
74
- n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns).wont_be_empty
75
- n.to.must_equal Blather::JID.new(host)
76
- n.type.must_equal :get
73
+ n.should be_instance_of Blather::Stanza::DiscoItems
74
+ n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns).should_not be_empty
75
+ n.to.should == Blather::JID.new(host)
76
+ n.type.should == :get
77
77
  end
78
78
  @pubsub.nodes nil, host
79
79
  end
80
80
 
81
81
  it 'requests nodes under a specified path' do
82
82
  @client.expects(:write_with_handler).with do |n|
83
- n.must_be_instance_of Blather::Stanza::DiscoItems
84
- n.find("/iq/ns:query[@node='/path/to/nodes']", :ns => Blather::Stanza::DiscoItems.registered_ns).wont_be_empty
85
- n.to.must_equal Blather::JID.new(@host)
86
- n.type.must_equal :get
83
+ n.should be_instance_of Blather::Stanza::DiscoItems
84
+ n.find("/iq/ns:query[@node='/path/to/nodes']", :ns => Blather::Stanza::DiscoItems.registered_ns).should_not be_empty
85
+ n.to.should == Blather::JID.new(@host)
86
+ n.type.should == :get
87
87
  end
88
88
  @pubsub.nodes '/path/to/nodes'
89
89
  end
90
90
 
91
91
  it 'requests information on a node' do
92
92
  @client.expects(:write_with_handler).with do |n|
93
- n.must_be_instance_of Blather::Stanza::DiscoInfo
94
- n.find("/iq/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::DiscoInfo.registered_ns).wont_be_empty
95
- n.to.must_equal Blather::JID.new(@host)
96
- n.type.must_equal :get
93
+ n.should be_instance_of Blather::Stanza::DiscoInfo
94
+ n.find("/iq/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::DiscoInfo.registered_ns).should_not be_empty
95
+ n.to.should == Blather::JID.new(@host)
96
+ n.type.should == :get
97
97
  end
98
98
  @pubsub.node '/path/to/node'
99
99
  end
100
100
 
101
101
  it 'requests all items from a node' do
102
102
  @client.expects(:write_with_handler).with do |n|
103
- n.must_be_instance_of Blather::Stanza::PubSub::Items
104
- n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
105
- n.to.must_equal Blather::JID.new(@host)
106
- n.type.must_equal :get
103
+ n.should be_instance_of Blather::Stanza::PubSub::Items
104
+ n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
105
+ n.to.should == Blather::JID.new(@host)
106
+ n.type.should == :get
107
107
  end
108
108
  @pubsub.items '/path/to/node'
109
109
  end
110
110
 
111
111
  it 'requests specific items from a node' do
112
112
  @client.expects(:write_with_handler).with do |n|
113
- n.must_be_instance_of Blather::Stanza::PubSub::Items
114
- n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node'][ns:item[@id='item1']][ns:item[@id='item2']]", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
115
- n.to.must_equal Blather::JID.new(@host)
116
- n.type.must_equal :get
113
+ n.should be_instance_of Blather::Stanza::PubSub::Items
114
+ n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node'][ns:item[@id='item1']][ns:item[@id='item2']]", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
115
+ n.to.should == Blather::JID.new(@host)
116
+ n.type.should == :get
117
117
  end
118
118
  @pubsub.items '/path/to/node', %w[item1 item2]
119
119
  end
120
120
 
121
121
  it 'requests some items from a node' do
122
122
  @client.expects(:write_with_handler).with do |n|
123
- n.must_be_instance_of Blather::Stanza::PubSub::Items
124
- n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node' and @max_items='2']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
125
- n.to.must_equal Blather::JID.new(@host)
126
- n.type.must_equal :get
123
+ n.should be_instance_of Blather::Stanza::PubSub::Items
124
+ n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node' and @max_items='2']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
125
+ n.to.should == Blather::JID.new(@host)
126
+ n.type.should == :get
127
127
  end
128
128
  @pubsub.items '/path/to/node', nil, 2
129
129
  end
130
130
 
131
131
  it 'can publish items to a node with a hash' do
132
132
  @client.expects(:write_with_handler).with do |n|
133
- n.must_be_instance_of Blather::Stanza::PubSub::Publish
134
- n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[@id='id1' and .='payload1'] and ns:item[@id='id2' and .='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
135
- n.to.must_equal Blather::JID.new(@host)
136
- n.type.must_equal :set
133
+ n.should be_instance_of Blather::Stanza::PubSub::Publish
134
+ n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[@id='id1' and .='payload1'] and ns:item[@id='id2' and .='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
135
+ n.to.should == Blather::JID.new(@host)
136
+ n.type.should == :set
137
137
  end
138
138
  @pubsub.publish '/path/to/node', {'id1' => 'payload1', 'id2' => 'payload2'}
139
139
  end
140
140
 
141
141
  it 'can publish items to a node with an array' do
142
142
  @client.expects(:write_with_handler).with do |n|
143
- n.must_be_instance_of Blather::Stanza::PubSub::Publish
144
- n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload1'] and ns:item[.='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
145
- n.to.must_equal Blather::JID.new(@host)
146
- n.type.must_equal :set
143
+ n.should be_instance_of Blather::Stanza::PubSub::Publish
144
+ n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload1'] and ns:item[.='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
145
+ n.to.should == Blather::JID.new(@host)
146
+ n.type.should == :set
147
147
  end
148
148
  @pubsub.publish '/path/to/node', %w[payload1 payload2]
149
149
  end
150
150
 
151
151
  it 'can publish items to a node with a string' do
152
152
  @client.expects(:write_with_handler).with do |n|
153
- n.must_be_instance_of Blather::Stanza::PubSub::Publish
154
- n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload']]", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
155
- n.to.must_equal Blather::JID.new(@host)
156
- n.type.must_equal :set
153
+ n.should be_instance_of Blather::Stanza::PubSub::Publish
154
+ n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload']]", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
155
+ n.to.should == Blather::JID.new(@host)
156
+ n.type.should == :set
157
157
  end
158
158
  @pubsub.publish '/path/to/node', 'payload'
159
159
  end
160
160
 
161
161
  it 'can retract an item with an array' do
162
162
  @client.expects(:write_with_handler).with do |n|
163
- n.must_be_instance_of Blather::Stanza::PubSub::Retract
164
- n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1'] and ns:item[@id='id2']]", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
165
- n.to.must_equal Blather::JID.new(@host)
166
- n.type.must_equal :set
163
+ n.should be_instance_of Blather::Stanza::PubSub::Retract
164
+ n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1'] and ns:item[@id='id2']]", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
165
+ n.to.should == Blather::JID.new(@host)
166
+ n.type.should == :set
167
167
  end
168
168
  @pubsub.retract '/path/to/node', %w[id1 id2]
169
169
  end
170
170
 
171
171
  it 'can retract an item with a string' do
172
172
  @client.expects(:write_with_handler).with do |n|
173
- n.must_be_instance_of Blather::Stanza::PubSub::Retract
174
- n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1']]", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
175
- n.to.must_equal Blather::JID.new(@host)
176
- n.type.must_equal :set
173
+ n.should be_instance_of Blather::Stanza::PubSub::Retract
174
+ n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1']]", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
175
+ n.to.should == Blather::JID.new(@host)
176
+ n.type.should == :set
177
177
  end
178
178
  @pubsub.retract '/path/to/node', 'id1'
179
179
  end
180
180
 
181
181
  it 'can subscribe to a node with the default jid' do
182
182
  @client.expects(:write_with_handler).with do |n|
183
- n.must_be_instance_of Blather::Stanza::PubSub::Subscribe
184
- n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
185
- n.to.must_equal Blather::JID.new(@host)
186
- n.type.must_equal :set
183
+ n.should be_instance_of Blather::Stanza::PubSub::Subscribe
184
+ n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
185
+ n.to.should == Blather::JID.new(@host)
186
+ n.type.should == :set
187
187
  end
188
188
  @pubsub.subscribe '/path/to/node'
189
189
  end
190
190
 
191
191
  it 'can subscribe to a node with a specified jid as a string' do
192
192
  @client.expects(:write_with_handler).with do |n|
193
- n.must_be_instance_of Blather::Stanza::PubSub::Subscribe
194
- n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
195
- n.to.must_equal Blather::JID.new(@host)
196
- n.type.must_equal :set
193
+ n.should be_instance_of Blather::Stanza::PubSub::Subscribe
194
+ n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
195
+ n.to.should == Blather::JID.new(@host)
196
+ n.type.should == :set
197
197
  end
198
198
  @pubsub.subscribe '/path/to/node', 'jid@d/r'
199
199
  end
200
200
 
201
201
  it 'can subscribe to a node with a specified jid as a Blather::JID' do
202
202
  @client.expects(:write_with_handler).with do |n|
203
- n.must_be_instance_of Blather::Stanza::PubSub::Subscribe
204
- n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
205
- n.to.must_equal Blather::JID.new(@host)
206
- n.type.must_equal :set
203
+ n.should be_instance_of Blather::Stanza::PubSub::Subscribe
204
+ n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
205
+ n.to.should == Blather::JID.new(@host)
206
+ n.type.should == :set
207
207
  end
208
208
  @pubsub.subscribe '/path/to/node', Blather::JID.new('jid@d/r')
209
209
  end
210
210
 
211
211
  it 'can unsubscribe to a node with the default jid' do
212
212
  @client.expects(:write_with_handler).with do |n|
213
- n.must_be_instance_of Blather::Stanza::PubSub::Unsubscribe
214
- n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
215
- n.to.must_equal Blather::JID.new(@host)
216
- n.type.must_equal :set
213
+ n.should be_instance_of Blather::Stanza::PubSub::Unsubscribe
214
+ n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
215
+ n.to.should == Blather::JID.new(@host)
216
+ n.type.should == :set
217
217
  end
218
218
  @pubsub.unsubscribe '/path/to/node'
219
219
  end
220
220
 
221
221
  it 'can unsubscribe to a node with a specified jid as a string' do
222
222
  @client.expects(:write_with_handler).with do |n|
223
- n.must_be_instance_of Blather::Stanza::PubSub::Unsubscribe
224
- n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
225
- n.to.must_equal Blather::JID.new(@host)
226
- n.type.must_equal :set
223
+ n.should be_instance_of Blather::Stanza::PubSub::Unsubscribe
224
+ n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
225
+ n.to.should == Blather::JID.new(@host)
226
+ n.type.should == :set
227
227
  end
228
228
  @pubsub.unsubscribe '/path/to/node', 'jid@d/r'
229
229
  end
230
230
 
231
231
  it 'can unsubscribe to a node with a specified jid as a Blather::JID' do
232
232
  @client.expects(:write_with_handler).with do |n|
233
- n.must_be_instance_of Blather::Stanza::PubSub::Unsubscribe
234
- n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
235
- n.to.must_equal Blather::JID.new(@host)
236
- n.type.must_equal :set
233
+ n.should be_instance_of Blather::Stanza::PubSub::Unsubscribe
234
+ n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
235
+ n.to.should == Blather::JID.new(@host)
236
+ n.type.should == :set
237
237
  end
238
238
  @pubsub.unsubscribe '/path/to/node', Blather::JID.new('jid@d/r')
239
239
  end
240
240
 
241
241
  it 'can unsubscribe with a particular subscription id' do
242
242
  @client.expects(:write_with_handler).with do |n|
243
- n.must_be_instance_of Blather::Stanza::PubSub::Unsubscribe
244
- n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r' and @subid='subid']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
245
- n.subid.must_equal 'subid'
246
- n.type.must_equal :set
243
+ n.should be_instance_of Blather::Stanza::PubSub::Unsubscribe
244
+ n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r' and @subid='subid']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
245
+ n.subid.should == 'subid'
246
+ n.type.should == :set
247
247
  end
248
248
  @pubsub.unsubscribe '/path/to/node', 'jid@d/r', 'subid'
249
249
  end
250
250
 
251
251
  it 'can purge a node' do
252
252
  @client.expects(:write_with_handler).with do |n|
253
- n.must_be_instance_of Blather::Stanza::PubSubOwner::Purge
254
- n.find("/iq[@type='set']/ns:pubsub/ns:purge[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns).wont_be_empty
255
- n.to.must_equal Blather::JID.new(@host)
256
- n.type.must_equal :set
253
+ n.should be_instance_of Blather::Stanza::PubSubOwner::Purge
254
+ n.find("/iq[@type='set']/ns:pubsub/ns:purge[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
255
+ n.to.should == Blather::JID.new(@host)
256
+ n.type.should == :set
257
257
  end
258
258
  @pubsub.purge '/path/to/node'
259
259
  end
260
260
 
261
261
  it 'can create a node' do
262
262
  @client.expects(:write_with_handler).with do |n|
263
- n.must_be_instance_of Blather::Stanza::PubSub::Create
264
- n.find("/iq[@type='set']/ns:pubsub/ns:create[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
265
- n.to.must_equal Blather::JID.new(@host)
266
- n.type.must_equal :set
263
+ n.should be_instance_of Blather::Stanza::PubSub::Create
264
+ n.find("/iq[@type='set']/ns:pubsub/ns:create[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
265
+ n.to.should == Blather::JID.new(@host)
266
+ n.type.should == :set
267
267
  end
268
268
  @pubsub.create '/path/to/node'
269
269
  end
270
270
 
271
271
  it 'can delete a node' do
272
272
  @client.expects(:write_with_handler).with do |n|
273
- n.must_be_instance_of Blather::Stanza::PubSubOwner::Delete
274
- n.find("/iq[@type='set']/ns:pubsub/ns:delete[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns).wont_be_empty
275
- n.to.must_equal Blather::JID.new(@host)
276
- n.type.must_equal :set
273
+ n.should be_instance_of Blather::Stanza::PubSubOwner::Delete
274
+ n.find("/iq[@type='set']/ns:pubsub/ns:delete[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
275
+ n.to.should == Blather::JID.new(@host)
276
+ n.type.should == :set
277
277
  end
278
278
  @pubsub.delete '/path/to/node'
279
279
  end
@@ -287,9 +287,9 @@ describe 'Blather::DSL::PubSub callbacks' do
287
287
  end
288
288
 
289
289
  it 'returns a list of affiliations when requesting affiliations' do
290
- affiliations = Blather::XMPPNode.import(parse_stanza(affiliations_xml).root)
290
+ affiliations = Blather::XMPPNode.parse(affiliations_xml)
291
291
  response = mock()
292
- response.expects(:call).with { |n| n.must_equal affiliations.list }
292
+ response.expects(:call).with { |n| n.should == affiliations.list }
293
293
  @client.stubs(:write).with do |n|
294
294
  affiliations.id = n.id
295
295
  @client.receive_data affiliations
@@ -299,9 +299,9 @@ describe 'Blather::DSL::PubSub callbacks' do
299
299
  end
300
300
 
301
301
  it 'returns a list of subscriptions when requesting subscriptions' do
302
- subscriptions = Blather::XMPPNode.import(parse_stanza(subscriptions_xml).root)
302
+ subscriptions = Blather::XMPPNode.parse(subscriptions_xml)
303
303
  response = mock()
304
- response.expects(:call).with { |n| n.must_equal subscriptions.list }
304
+ response.expects(:call).with { |n| n.should == subscriptions.list }
305
305
  @client.stubs(:write).with do |n|
306
306
  subscriptions.id = n.id
307
307
  @client.receive_data subscriptions
@@ -311,7 +311,7 @@ describe 'Blather::DSL::PubSub callbacks' do
311
311
  end
312
312
 
313
313
  it 'returns a list of node items when requesting nodes' do
314
- nodes = Blather::XMPPNode.import(parse_stanza(<<-NODES).root)
314
+ nodes = Blather::XMPPNode.parse(<<-NODES)
315
315
  <iq type='result'
316
316
  from='pubsub.shakespeare.lit'
317
317
  to='francisco@denmark.lit/barracks'
@@ -327,7 +327,7 @@ describe 'Blather::DSL::PubSub callbacks' do
327
327
  </iq>
328
328
  NODES
329
329
  response = mock()
330
- response.expects(:call).with { |n| n.must_equal nodes.items }
330
+ response.expects(:call).with { |n| n.should == nodes.items }
331
331
  @client.stubs(:write).with do |n|
332
332
  nodes.id = n.id
333
333
  @client.receive_data nodes
@@ -337,7 +337,7 @@ describe 'Blather::DSL::PubSub callbacks' do
337
337
  end
338
338
 
339
339
  it 'returns a DiscoInfo node when requesting a node' do
340
- node = Blather::XMPPNode.import(parse_stanza(<<-NODES).root)
340
+ node = Blather::XMPPNode.parse(<<-NODES)
341
341
  <iq type='result'
342
342
  from='pubsub.shakespeare.lit'
343
343
  to='francisco@denmark.lit/barracks'
@@ -349,7 +349,7 @@ describe 'Blather::DSL::PubSub callbacks' do
349
349
  </iq>
350
350
  NODES
351
351
  response = mock()
352
- response.expects(:call).with { |n| n.must_equal node }
352
+ response.expects(:call).with { |n| n.should == node }
353
353
  @client.stubs(:write).with do |n|
354
354
  node.id = n.id
355
355
  @client.receive_data node
@@ -359,9 +359,9 @@ describe 'Blather::DSL::PubSub callbacks' do
359
359
  end
360
360
 
361
361
  it 'returns a set of items when requesting items' do
362
- items = Blather::XMPPNode.import(parse_stanza(items_all_nodes_xml).root)
362
+ items = Blather::XMPPNode.parse(items_all_nodes_xml)
363
363
  response = mock()
364
- response.expects(:call).with { |n| n.map{|i|i.to_s}.must_equal items.items.map{|i|i.to_s} }
364
+ response.expects(:call).with { |n| n.map{|i|i.to_s}.should == items.items.map{|i|i.to_s} }
365
365
  @client.stubs(:write).with do |n|
366
366
  items.id = n.id
367
367
  @client.receive_data items
@@ -371,9 +371,9 @@ describe 'Blather::DSL::PubSub callbacks' do
371
371
  end
372
372
 
373
373
  it 'returns aa subscription node when subscribing' do
374
- subscription = Blather::XMPPNode.import(parse_stanza(subscription_xml).root)
374
+ subscription = Blather::XMPPNode.parse(subscription_xml)
375
375
  response = mock()
376
- response.expects(:call).with { |n| n.must_equal subscription }
376
+ response.expects(:call).with { |n| n.should == subscription }
377
377
  @client.stubs(:write).with do |n|
378
378
  subscription.id = n.id
379
379
  @client.receive_data subscription
@@ -383,9 +383,9 @@ describe 'Blather::DSL::PubSub callbacks' do
383
383
  end
384
384
 
385
385
  it 'returns aa unsubscribe node when unsubscribing' do
386
- unsubscribe = Blather::XMPPNode.import(parse_stanza(unsubscribe_xml).root)
386
+ unsubscribe = Blather::XMPPNode.parse(unsubscribe_xml)
387
387
  response = mock()
388
- response.expects(:call).with { |n| n.must_equal unsubscribe }
388
+ response.expects(:call).with { |n| n.should == unsubscribe }
389
389
  @client.stubs(:write).with do |n|
390
390
  unsubscribe.id = n.id
391
391
  @client.receive_data unsubscribe
@@ -395,7 +395,7 @@ describe 'Blather::DSL::PubSub callbacks' do
395
395
  end
396
396
 
397
397
  it 'returns a publish result when publishing to a node' do
398
- result = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
398
+ result = Blather::XMPPNode.parse(<<-NODE)
399
399
  <iq type='result'
400
400
  from='pubsub.shakespeare.lit'
401
401
  to='hamlet@denmark.lit/blogbot'
@@ -408,7 +408,7 @@ describe 'Blather::DSL::PubSub callbacks' do
408
408
  </iq>
409
409
  NODE
410
410
  response = mock()
411
- response.expects(:call).with { |n| n.must_equal result }
411
+ response.expects(:call).with { |n| n.should == result }
412
412
  @client.stubs(:write).with do |n|
413
413
  result.id = n.id
414
414
  @client.receive_data result
@@ -418,7 +418,7 @@ describe 'Blather::DSL::PubSub callbacks' do
418
418
  end
419
419
 
420
420
  it 'returns a create result when creating a node' do
421
- result = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
421
+ result = Blather::XMPPNode.parse(<<-NODE)
422
422
  <iq type='result'
423
423
  from='pubsub.shakespeare.lit'
424
424
  to='hamlet@denmark.lit/elsinore'
@@ -429,7 +429,7 @@ describe 'Blather::DSL::PubSub callbacks' do
429
429
  </iq>
430
430
  NODE
431
431
  response = mock()
432
- response.expects(:call).with { |n| n.must_equal result }
432
+ response.expects(:call).with { |n| n.should == result }
433
433
  @client.stubs(:write).with do |n|
434
434
  result.id = n.id
435
435
  @client.receive_data result
@@ -439,13 +439,13 @@ describe 'Blather::DSL::PubSub callbacks' do
439
439
  end
440
440
 
441
441
  it 'returns a purge result when purging a node' do
442
- result = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
442
+ result = Blather::XMPPNode.parse(<<-NODE)
443
443
  <iq type='result'
444
444
  from='pubsub.shakespeare.lit'
445
445
  id='purge1'/>
446
446
  NODE
447
447
  response = mock()
448
- response.expects(:call).with { |n| n.must_equal result }
448
+ response.expects(:call).with { |n| n.should == result }
449
449
  @client.stubs(:write).with do |n|
450
450
  result.id = n.id
451
451
  @client.receive_data result
@@ -455,13 +455,13 @@ describe 'Blather::DSL::PubSub callbacks' do
455
455
  end
456
456
 
457
457
  it 'returns a delete result when deleting a node' do
458
- result = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
458
+ result = Blather::XMPPNode.parse(<<-NODE)
459
459
  <iq type='result'
460
460
  from='pubsub.shakespeare.lit'
461
461
  id='delete1'/>
462
462
  NODE
463
463
  response = mock()
464
- response.expects(:call).with { |n| n.must_equal result }
464
+ response.expects(:call).with { |n| n.should == result }
465
465
  @client.stubs(:write).with do |n|
466
466
  result.id = n.id
467
467
  @client.receive_data result