blather 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +7 -7
  3. data/CHANGELOG.md +8 -0
  4. data/blather.gemspec +6 -6
  5. data/lib/blather.rb +1 -1
  6. data/lib/blather/client/client.rb +30 -6
  7. data/lib/blather/version.rb +1 -1
  8. data/spec/blather/client/client_spec.rb +73 -68
  9. data/spec/blather/client/dsl/pubsub_spec.rb +121 -121
  10. data/spec/blather/client/dsl_spec.rb +9 -9
  11. data/spec/blather/errors/sasl_error_spec.rb +3 -3
  12. data/spec/blather/errors/stanza_error_spec.rb +26 -26
  13. data/spec/blather/errors/stream_error_spec.rb +22 -22
  14. data/spec/blather/errors_spec.rb +7 -7
  15. data/spec/blather/file_transfer_spec.rb +9 -9
  16. data/spec/blather/jid_spec.rb +29 -29
  17. data/spec/blather/roster_item_spec.rb +18 -18
  18. data/spec/blather/roster_spec.rb +18 -18
  19. data/spec/blather/stanza/discos/disco_info_spec.rb +56 -56
  20. data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
  21. data/spec/blather/stanza/iq/command_spec.rb +51 -51
  22. data/spec/blather/stanza/iq/ibb_spec.rb +15 -15
  23. data/spec/blather/stanza/iq/ping_spec.rb +8 -8
  24. data/spec/blather/stanza/iq/query_spec.rb +15 -15
  25. data/spec/blather/stanza/iq/roster_spec.rb +29 -29
  26. data/spec/blather/stanza/iq/s5b_spec.rb +7 -7
  27. data/spec/blather/stanza/iq/si_spec.rb +17 -17
  28. data/spec/blather/stanza/iq/vcard_spec.rb +19 -19
  29. data/spec/blather/stanza/iq_spec.rb +11 -11
  30. data/spec/blather/stanza/message/muc_user_spec.rb +32 -32
  31. data/spec/blather/stanza/message_spec.rb +53 -54
  32. data/spec/blather/stanza/presence/c_spec.rb +11 -11
  33. data/spec/blather/stanza/presence/muc_spec.rb +7 -7
  34. data/spec/blather/stanza/presence/muc_user_spec.rb +22 -22
  35. data/spec/blather/stanza/presence/status_spec.rb +33 -33
  36. data/spec/blather/stanza/presence/subscription_spec.rb +22 -22
  37. data/spec/blather/stanza/presence_spec.rb +30 -30
  38. data/spec/blather/stanza/pubsub/affiliations_spec.rb +11 -11
  39. data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
  40. data/spec/blather/stanza/pubsub/event_spec.rb +24 -24
  41. data/spec/blather/stanza/pubsub/items_spec.rb +20 -20
  42. data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
  43. data/spec/blather/stanza/pubsub/retract_spec.rb +19 -19
  44. data/spec/blather/stanza/pubsub/subscribe_spec.rb +17 -17
  45. data/spec/blather/stanza/pubsub/subscription_spec.rb +28 -28
  46. data/spec/blather/stanza/pubsub/subscriptions_spec.rb +13 -13
  47. data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +22 -22
  48. data/spec/blather/stanza/pubsub_owner/delete_spec.rb +9 -9
  49. data/spec/blather/stanza/pubsub_owner/purge_spec.rb +9 -9
  50. data/spec/blather/stanza/pubsub_owner_spec.rb +6 -6
  51. data/spec/blather/stanza/pubsub_spec.rb +15 -15
  52. data/spec/blather/stanza/x_spec.rb +53 -53
  53. data/spec/blather/stanza_spec.rb +39 -39
  54. data/spec/blather/stream/client_spec.rb +160 -160
  55. data/spec/blather/stream/component_spec.rb +8 -10
  56. data/spec/blather/stream/parser_spec.rb +25 -25
  57. data/spec/blather/stream/ssl_spec.rb +3 -3
  58. data/spec/blather/xmpp_node_spec.rb +9 -9
  59. data/spec/blather_spec.rb +1 -1
  60. data/spec/spec_helper.rb +1 -1
  61. metadata +26 -27
@@ -2,44 +2,44 @@ require 'spec_helper'
2
2
 
3
3
  describe Blather::Stanza::Iq do
4
4
  it 'registers itself' do
5
- Blather::XMPPNode.class_from_registration(:iq, nil).should == Blather::Stanza::Iq
5
+ expect(Blather::XMPPNode.class_from_registration(:iq, nil)).to eq(Blather::Stanza::Iq)
6
6
  end
7
7
 
8
8
  it 'must be importable' do
9
9
  string = "<iq from='juliet@example.com/balcony' type='set' id='roster_4'></iq>"
10
- Blather::XMPPNode.parse(string).should be_instance_of Blather::Stanza::Iq
10
+ expect(Blather::XMPPNode.parse(string)).to be_instance_of Blather::Stanza::Iq
11
11
  end
12
12
 
13
13
  it 'creates a new Iq stanza defaulted as a get' do
14
- Blather::Stanza::Iq.new.type.should == :get
14
+ expect(Blather::Stanza::Iq.new.type).to eq(:get)
15
15
  end
16
16
 
17
17
  it 'sets the id when created' do
18
- Blather::Stanza::Iq.new.id.should_not be_nil
18
+ expect(Blather::Stanza::Iq.new.id).not_to be_nil
19
19
  end
20
20
 
21
21
  it 'creates a new Stanza::Iq object on import' do
22
- Blather::Stanza::Iq.import(Blather::XMPPNode.new('iq')).should be_kind_of Blather::Stanza::Iq
22
+ expect(Blather::Stanza::Iq.import(Blather::XMPPNode.new('iq'))).to be_kind_of Blather::Stanza::Iq
23
23
  end
24
24
 
25
25
  it 'creates a proper object based on its children' do
26
26
  n = Blather::XMPPNode.new('iq')
27
27
  n << Blather::XMPPNode.new('query', n.document)
28
- Blather::Stanza::Iq.import(n).should be_kind_of Blather::Stanza::Iq::Query
28
+ expect(Blather::Stanza::Iq.import(n)).to be_kind_of Blather::Stanza::Iq::Query
29
29
  end
30
30
 
31
31
  it 'ensures type is one of Stanza::Iq::VALID_TYPES' do
32
- lambda { Blather::Stanza::Iq.new :invalid_type_name }.should raise_error(Blather::ArgumentError)
32
+ expect { Blather::Stanza::Iq.new :invalid_type_name }.to raise_error(Blather::ArgumentError)
33
33
 
34
34
  Blather::Stanza::Iq::VALID_TYPES.each do |valid_type|
35
35
  n = Blather::Stanza::Iq.new valid_type
36
- n.type.should == valid_type
36
+ expect(n.type).to eq(valid_type)
37
37
  end
38
38
  end
39
39
 
40
40
  Blather::Stanza::Iq::VALID_TYPES.each do |valid_type|
41
41
  it "provides a helper (#{valid_type}?) for type #{valid_type}" do
42
- Blather::Stanza::Iq.new.should respond_to :"#{valid_type}?"
42
+ expect(Blather::Stanza::Iq.new).to respond_to :"#{valid_type}?"
43
43
  end
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ describe Blather::Stanza::Iq do
48
48
  iq.from = 'them@example.com'
49
49
  iq << Blather::XMPPNode.new('query', iq.document)
50
50
  r = iq.reply
51
- r.children.empty?.should == true
51
+ expect(r.children.empty?).to eq(true)
52
52
  end
53
53
 
54
54
  it 'does not remove the body when replying if we ask to keep it' do
@@ -56,6 +56,6 @@ describe Blather::Stanza::Iq do
56
56
  iq.from = 'them@example.com'
57
57
  iq << Blather::XMPPNode.new('query', iq.document)
58
58
  r = iq.reply :remove_children => false
59
- r.children.empty?.should == false
59
+ expect(r.children.empty?).to eq(false)
60
60
  end
61
61
  end
@@ -38,115 +38,115 @@ end
38
38
  describe 'Blather::Stanza::Message::MUCUser' do
39
39
  it 'ensures a form node is present on create' do
40
40
  c = Blather::Stanza::Message::MUCUser.new
41
- c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).should_not be_empty
41
+ expect(c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns)).not_to be_empty
42
42
  end
43
43
 
44
44
  it 'ensures a form node exists when calling #muc' do
45
45
  c = Blather::Stanza::Message::MUCUser.new
46
46
  c.remove_children :x
47
- c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).should be_empty
47
+ expect(c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns)).to be_empty
48
48
 
49
- c.muc_user.should_not be_nil
50
- c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).should_not be_empty
49
+ expect(c.muc_user).not_to be_nil
50
+ expect(c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns)).not_to be_empty
51
51
  end
52
52
 
53
53
  it 'ensures the message type is :normal' do
54
54
  m = Blather::Stanza::Message::MUCUser.new
55
- m.normal?.should == true
55
+ expect(m.normal?).to eq(true)
56
56
  end
57
57
 
58
58
  it "must be able to set the password" do
59
59
  muc_user = Blather::Stanza::Message::MUCUser.new
60
- muc_user.password.should == nil
60
+ expect(muc_user.password).to eq(nil)
61
61
  muc_user.password = 'barbaz'
62
- muc_user.password.should == 'barbaz'
62
+ expect(muc_user.password).to eq('barbaz')
63
63
  muc_user.password = 'hello_world'
64
- muc_user.password.should == 'hello_world'
64
+ expect(muc_user.password).to eq('hello_world')
65
65
  end
66
66
 
67
67
  it "should not be an #invite?" do
68
68
  muc_user = Blather::Stanza::Message::MUCUser.new
69
- muc_user.invite?.should == false
69
+ expect(muc_user.invite?).to eq(false)
70
70
  end
71
71
 
72
72
  describe "with an invite element" do
73
73
  it "should be an #invite?" do
74
74
  muc_user = Blather::XMPPNode.parse(muc_invite_xml)
75
- muc_user.invite?.should == true
75
+ expect(muc_user.invite?).to eq(true)
76
76
  end
77
77
 
78
78
  it "should know the invite attributes properly" do
79
79
  muc_user = Blather::XMPPNode.parse(muc_invite_xml)
80
- muc_user.should be_instance_of Blather::Stanza::Message::MUCUser
80
+ expect(muc_user).to be_instance_of Blather::Stanza::Message::MUCUser
81
81
  invite = muc_user.invite
82
- invite.to.should == 'hecate@shakespeare.lit'
83
- invite.from.should == 'crone1@shakespeare.lit/desktop'
84
- invite.reason.should == 'Hey Hecate, this is the place for all good witches!'
85
- muc_user.password.should == 'foobar'
82
+ expect(invite.to).to eq('hecate@shakespeare.lit')
83
+ expect(invite.from).to eq('crone1@shakespeare.lit/desktop')
84
+ expect(invite.reason).to eq('Hey Hecate, this is the place for all good witches!')
85
+ expect(muc_user.password).to eq('foobar')
86
86
  end
87
87
 
88
88
  it "must be able to set the to jid" do
89
89
  muc_user = Blather::Stanza::Message::MUCUser.new
90
90
  invite = muc_user.invite
91
- invite.to.should == nil
91
+ expect(invite.to).to eq(nil)
92
92
  invite.to = 'foo@bar.com'
93
- invite.to.should == 'foo@bar.com'
93
+ expect(invite.to).to eq('foo@bar.com')
94
94
  end
95
95
 
96
96
  it "must be able to set the from jid" do
97
97
  muc_user = Blather::Stanza::Message::MUCUser.new
98
98
  invite = muc_user.invite
99
- invite.from.should == nil
99
+ expect(invite.from).to eq(nil)
100
100
  invite.from = 'foo@bar.com'
101
- invite.from.should == 'foo@bar.com'
101
+ expect(invite.from).to eq('foo@bar.com')
102
102
  end
103
103
 
104
104
  it "must be able to set the reason" do
105
105
  muc_user = Blather::Stanza::Message::MUCUser.new
106
106
  invite = muc_user.invite
107
- invite.reason.should == ''
107
+ expect(invite.reason).to eq('')
108
108
  invite.reason = 'Please join'
109
- invite.reason.should == 'Please join'
109
+ expect(invite.reason).to eq('Please join')
110
110
  end
111
111
  end
112
112
 
113
113
  describe "with a decline element" do
114
114
  it "should be an #invite_decline?" do
115
115
  muc_user = Blather::XMPPNode.parse(muc_decline_xml)
116
- muc_user.should be_instance_of Blather::Stanza::Message::MUCUser
117
- muc_user.invite_decline?.should == true
116
+ expect(muc_user).to be_instance_of Blather::Stanza::Message::MUCUser
117
+ expect(muc_user.invite_decline?).to eq(true)
118
118
  end
119
119
 
120
120
  it "should know the decline attributes properly" do
121
121
  muc_user = Blather::XMPPNode.parse(muc_decline_xml)
122
122
  decline = muc_user.decline
123
- decline.to.should == 'crone1@shakespeare.lit'
124
- decline.from.should == 'hecate@shakespeare.lit'
125
- decline.reason.should == "Sorry, I'm too busy right now."
123
+ expect(decline.to).to eq('crone1@shakespeare.lit')
124
+ expect(decline.from).to eq('hecate@shakespeare.lit')
125
+ expect(decline.reason).to eq("Sorry, I'm too busy right now.")
126
126
  end
127
127
 
128
128
  it "must be able to set the to jid" do
129
129
  muc_user = Blather::Stanza::Message::MUCUser.new
130
130
  decline = muc_user.decline
131
- decline.to.should == nil
131
+ expect(decline.to).to eq(nil)
132
132
  decline.to = 'foo@bar.com'
133
- decline.to.should == 'foo@bar.com'
133
+ expect(decline.to).to eq('foo@bar.com')
134
134
  end
135
135
 
136
136
  it "must be able to set the from jid" do
137
137
  muc_user = Blather::Stanza::Message::MUCUser.new
138
138
  decline = muc_user.decline
139
- decline.from.should == nil
139
+ expect(decline.from).to eq(nil)
140
140
  decline.from = 'foo@bar.com'
141
- decline.from.should == 'foo@bar.com'
141
+ expect(decline.from).to eq('foo@bar.com')
142
142
  end
143
143
 
144
144
  it "must be able to set the reason" do
145
145
  muc_user = Blather::Stanza::Message::MUCUser.new
146
146
  decline = muc_user.decline
147
- decline.reason.should == ''
147
+ expect(decline.reason).to eq('')
148
148
  decline.reason = 'Please join'
149
- decline.reason.should == 'Please join'
149
+ expect(decline.reason).to eq('Please join')
150
150
  end
151
151
  end
152
152
  end
@@ -70,67 +70,67 @@ end
70
70
 
71
71
  describe Blather::Stanza::Message do
72
72
  it 'registers itself' do
73
- Blather::XMPPNode.class_from_registration(:message, nil).should == Blather::Stanza::Message
73
+ expect(Blather::XMPPNode.class_from_registration(:message, nil)).to eq(Blather::Stanza::Message)
74
74
  end
75
75
 
76
76
  it 'must be importable' do
77
- Blather::XMPPNode.parse(message_xml).should be_instance_of Blather::Stanza::Message
78
- Blather::XMPPNode.parse(ichat_message_xml).should be_instance_of Blather::Stanza::Message
77
+ expect(Blather::XMPPNode.parse(message_xml)).to be_instance_of Blather::Stanza::Message
78
+ expect(Blather::XMPPNode.parse(ichat_message_xml)).to be_instance_of Blather::Stanza::Message
79
79
  end
80
80
 
81
81
  it 'provides "attr_accessor" for body' do
82
82
  s = Blather::Stanza::Message.new
83
- s.body.should be_nil
84
- s.find('body').should be_empty
83
+ expect(s.body).to be_nil
84
+ expect(s.find('body')).to be_empty
85
85
 
86
86
  s.body = 'test message'
87
- s.body.should_not be_nil
88
- s.find('body').should_not be_empty
87
+ expect(s.body).not_to be_nil
88
+ expect(s.find('body')).not_to be_empty
89
89
  end
90
90
 
91
91
  it 'provides "attr_accessor" for subject' do
92
92
  s = Blather::Stanza::Message.new
93
- s.subject.should be_nil
94
- s.find('subject').should be_empty
93
+ expect(s.subject).to be_nil
94
+ expect(s.find('subject')).to be_empty
95
95
 
96
96
  s.subject = 'test subject'
97
- s.subject.should_not be_nil
98
- s.find('subject').should_not be_empty
97
+ expect(s.subject).not_to be_nil
98
+ expect(s.find('subject')).not_to be_empty
99
99
  end
100
100
 
101
101
  it 'provides "attr_accessor" for thread' do
102
102
  s = Blather::Stanza::Message.new
103
- s.thread.should be_nil
104
- s.find('thread').should be_empty
103
+ expect(s.thread).to be_nil
104
+ expect(s.find('thread')).to be_empty
105
105
 
106
106
  s.thread = 1234
107
- s.thread.should_not be_nil
108
- s.find('thread').should_not be_empty
107
+ expect(s.thread).not_to be_nil
108
+ expect(s.find('thread')).not_to be_empty
109
109
  end
110
110
 
111
111
  it 'can set a parent attribute for thread' do
112
112
  s = Blather::Stanza::Message.new
113
- s.thread.should be_nil
114
- s.find('thread').should be_empty
113
+ expect(s.thread).to be_nil
114
+ expect(s.find('thread')).to be_empty
115
115
 
116
116
  s.thread = {4321 => 1234}
117
- s.thread.should == '1234'
118
- s.parent_thread.should == '4321'
119
- s.find('thread[@parent="4321"]').should_not be_empty
117
+ expect(s.thread).to eq('1234')
118
+ expect(s.parent_thread).to eq('4321')
119
+ expect(s.find('thread[@parent="4321"]')).not_to be_empty
120
120
  end
121
121
 
122
122
  it 'ensures type is one of Blather::Stanza::Message::VALID_TYPES' do
123
- lambda { Blather::Stanza::Message.new nil, nil, :invalid_type_name }.should raise_error(Blather::ArgumentError)
123
+ expect { Blather::Stanza::Message.new nil, nil, :invalid_type_name }.to raise_error(Blather::ArgumentError)
124
124
 
125
125
  Blather::Stanza::Message::VALID_TYPES.each do |valid_type|
126
126
  msg = Blather::Stanza::Message.new nil, nil, valid_type
127
- msg.type.should == valid_type
127
+ expect(msg.type).to eq(valid_type)
128
128
  end
129
129
  end
130
130
 
131
131
  Blather::Stanza::Message::VALID_TYPES.each do |valid_type|
132
132
  it "provides a helper (#{valid_type}?) for type #{valid_type}" do
133
- Blather::Stanza::Message.new.should respond_to :"#{valid_type}?"
133
+ expect(Blather::Stanza::Message.new).to respond_to :"#{valid_type}?"
134
134
  end
135
135
  end
136
136
 
@@ -140,10 +140,10 @@ describe Blather::Stanza::Message do
140
140
  {:html_ns => Blather::Stanza::Message::HTML_NS}
141
141
  ]
142
142
  msg = Blather::Stanza::Message.new
143
- msg.find_first(*search_args).should be_nil
143
+ expect(msg.find_first(*search_args)).to be_nil
144
144
 
145
145
  msg.xhtml_node
146
- msg.find_first(*search_args).should_not be_nil
146
+ expect(msg.find_first(*search_args)).not_to be_nil
147
147
  end
148
148
 
149
149
  it 'ensures a body node exists when asked for xhtml_node' do
@@ -153,10 +153,10 @@ describe Blather::Stanza::Message do
153
153
  :body_ns => Blather::Stanza::Message::HTML_BODY_NS}
154
154
  ]
155
155
  msg = Blather::Stanza::Message.new
156
- msg.find_first(*search_args).should be_nil
156
+ expect(msg.find_first(*search_args)).to be_nil
157
157
 
158
158
  msg.xhtml_node
159
- msg.find_first(*search_args).should_not be_nil
159
+ expect(msg.find_first(*search_args)).not_to be_nil
160
160
  end
161
161
 
162
162
  it 'returns an existing node when asked for xhtml_node' do
@@ -167,47 +167,46 @@ describe Blather::Stanza::Message do
167
167
  b.namespace = Blather::Stanza::Message::HTML_BODY_NS
168
168
  h << b
169
169
 
170
- msg.xhtml_node.should ==(b)
170
+ expect(msg.xhtml_node).to eq(b)
171
171
  end
172
172
 
173
173
  it 'has an xhtml setter' do
174
174
  msg = Blather::Stanza::Message.new
175
175
  xhtml = "<some>xhtml</some>"
176
176
  msg.xhtml = xhtml
177
- msg.xhtml_node.inner_html.strip.should ==(xhtml)
177
+ expect(msg.xhtml_node.inner_html.strip).to eq(xhtml)
178
178
  end
179
179
 
180
180
  it 'sets valid xhtml even if the input is not valid' do
181
- pending "Nokogiri doesn't handle invalid HTML on JRuby" if jruby?
182
181
  msg = Blather::Stanza::Message.new
183
182
  xhtml = "<some>xhtml"
184
183
  msg.xhtml = xhtml
185
- msg.xhtml_node.inner_html.strip.should == "<some>xhtml</some>"
184
+ expect(msg.xhtml_node.inner_html.strip).to eq("<some>xhtml</some>")
186
185
  end
187
186
 
188
187
  it 'sets xhtml with more than one root node' do
189
188
  msg = Blather::Stanza::Message.new
190
189
  xhtml = "<i>xhtml</i> more xhtml"
191
190
  msg.xhtml = xhtml
192
- msg.xhtml_node.inner_html.strip.should ==("<i>xhtml</i> more xhtml")
191
+ expect(msg.xhtml_node.inner_html.strip).to eq("<i>xhtml</i> more xhtml")
193
192
  end
194
193
 
195
194
  it 'has an xhtml getter' do
196
195
  msg = Blather::Stanza::Message.new
197
196
  xhtml = "<some>xhtml</some>"
198
197
  msg.xhtml = xhtml
199
- msg.xhtml.should ==(xhtml)
198
+ expect(msg.xhtml).to eq(xhtml)
200
199
  end
201
200
 
202
201
  it 'finds xhtml body when html wrapper has wrong namespace' do
203
202
  msg = Blather::XMPPNode.parse(ichat_message_xml)
204
- Nokogiri::XML(msg.xhtml).to_xml.should == Nokogiri::XML("<span style=\"font-family: 'Arial';font-size: 12px;color: #262626;\">Hello</span>\n <img alt=\"f5ad3a04d218d7160fa02415e02d41b3.jpg\" src=\"message-attachments:1\" width=\"30\" height=\"30\"></img>").to_xml
203
+ expect(Nokogiri::XML(msg.xhtml).to_xml).to eq(Nokogiri::XML("<span style=\"font-family: 'Arial';font-size: 12px;color: #262626;\">Hello</span>\n <img alt=\"f5ad3a04d218d7160fa02415e02d41b3.jpg\" src=\"message-attachments:1\" width=\"30\" height=\"30\"></img>").to_xml)
205
204
  end
206
205
 
207
206
  it 'has a chat state setter' do
208
207
  msg = Blather::Stanza::Message.new
209
208
  msg.chat_state = :composing
210
- msg.xpath('ns:composing', :ns => Blather::Stanza::Message::CHAT_STATE_NS).should_not be_empty
209
+ expect(msg.xpath('ns:composing', :ns => Blather::Stanza::Message::CHAT_STATE_NS)).not_to be_empty
211
210
  end
212
211
 
213
212
  it 'will only add one chat state at a time' do
@@ -215,69 +214,69 @@ describe Blather::Stanza::Message do
215
214
  msg.chat_state = :composing
216
215
  msg.chat_state = :paused
217
216
 
218
- msg.xpath('ns:*', :ns => Blather::Stanza::Message::CHAT_STATE_NS).size.should ==(1)
217
+ expect(msg.xpath('ns:*', :ns => Blather::Stanza::Message::CHAT_STATE_NS).size).to eq(1)
219
218
  end
220
219
 
221
220
  it 'ensures chat state setter accepts strings' do
222
221
  msg = Blather::Stanza::Message.new
223
222
  msg.chat_state = "gone"
224
- msg.xpath('ns:gone', :ns => Blather::Stanza::Message::CHAT_STATE_NS).should_not be_empty
223
+ expect(msg.xpath('ns:gone', :ns => Blather::Stanza::Message::CHAT_STATE_NS)).not_to be_empty
225
224
  end
226
225
 
227
226
  it 'ensures chat state is one of Blather::Stanza::Message::VALID_CHAT_STATES' do
228
- lambda do
227
+ expect do
229
228
  msg = Blather::Stanza::Message.new
230
229
  msg.chat_state = :invalid_chat_state
231
- end.should raise_error(Blather::ArgumentError)
230
+ end.to raise_error(Blather::ArgumentError)
232
231
 
233
232
  Blather::Stanza::Message::VALID_CHAT_STATES.each do |valid_chat_state|
234
233
  msg = Blather::Stanza::Message.new
235
234
  msg.chat_state = valid_chat_state
236
- msg.chat_state.should == valid_chat_state
235
+ expect(msg.chat_state).to eq(valid_chat_state)
237
236
  end
238
237
  end
239
238
 
240
239
  it 'has a chat state getter' do
241
240
  msg = Blather::Stanza::Message.new
242
241
  msg.chat_state = :paused
243
- msg.chat_state.should ==(:paused)
242
+ expect(msg.chat_state).to eq(:paused)
244
243
  end
245
244
 
246
245
  it 'imports correct chat state' do
247
- Blather::XMPPNode.parse(message_xml).chat_state.should == :paused
246
+ expect(Blather::XMPPNode.parse(message_xml).chat_state).to eq(:paused)
248
247
  end
249
248
 
250
249
  it 'makes a form child available' do
251
250
  n = Blather::XMPPNode.parse(message_xml)
252
- n.form.fields.size.should == 1
253
- n.form.fields.map { |f| f.class }.uniq.should == [Blather::Stanza::X::Field]
254
- n.form.should be_instance_of Blather::Stanza::X
251
+ expect(n.form.fields.size).to eq(1)
252
+ expect(n.form.fields.map { |f| f.class }.uniq).to eq([Blather::Stanza::X::Field])
253
+ expect(n.form).to be_instance_of Blather::Stanza::X
255
254
 
256
255
  r = Blather::Stanza::Message.new
257
256
  r.form.type = :form
258
- r.form.type.should == :form
257
+ expect(r.form.type).to eq(:form)
259
258
  end
260
259
 
261
260
  it 'ensures the form child is a direct child' do
262
261
  r = Blather::Stanza::Message.new
263
262
  r.form
264
- r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns).should_not be_empty
263
+ expect(r.xpath('ns:x', :ns => Blather::Stanza::X.registered_ns)).not_to be_empty
265
264
  end
266
265
 
267
266
  it 'is not delayed' do
268
267
  n = Blather::XMPPNode.parse(message_xml)
269
- n.delay.should == nil
270
- n.delayed?.should == false
268
+ expect(n.delay).to eq(nil)
269
+ expect(n.delayed?).to eq(false)
271
270
  end
272
271
 
273
272
  describe "with a delay" do
274
273
  it "is delayed" do
275
274
  n = Blather::XMPPNode.parse(delayed_message_xml)
276
- n.delayed?.should == true
277
- n.delay.should be_instance_of Blather::Stanza::Message::Delay
278
- n.delay.from.should == 'coven@chat.shakespeare.lit'
279
- n.delay.stamp.should == Time.utc(2002, 10, 13, 23, 58, 37, 0)
280
- n.delay.description.should == "Too slow"
275
+ expect(n.delayed?).to eq(true)
276
+ expect(n.delay).to be_instance_of Blather::Stanza::Message::Delay
277
+ expect(n.delay.from).to eq('coven@chat.shakespeare.lit')
278
+ expect(n.delay.stamp).to eq(Time.utc(2002, 10, 13, 23, 58, 37, 0))
279
+ expect(n.delay.description).to eq("Too slow")
281
280
  end
282
281
  end
283
282
  end