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
@@ -109,7 +109,7 @@ describe Blather::DSL do
109
109
  it 'provides a << style writer that provides chaining' do
110
110
  stanza = Blather::Stanza::Iq.new
111
111
  @client.expects(:write).with stanza
112
- (@dsl << stanza).should == @dsl
112
+ expect(@dsl << stanza).to eq(@dsl)
113
113
  end
114
114
 
115
115
  it 'provides a writer' do
@@ -173,7 +173,7 @@ describe Blather::DSL do
173
173
  end
174
174
 
175
175
  it 'provides a caps set helper' do
176
- @dsl.should respond_to :set_caps
176
+ expect(@dsl).to respond_to :set_caps
177
177
  node = 'http://code.google.com/p/exodus'
178
178
  identities = [Blather::Stanza::Iq::DiscoInfo::Identity.new({:name => 'Exodus 0.9.1', :type => 'pc', :category => 'client'})]
179
179
  features = %w{
@@ -183,13 +183,13 @@ describe Blather::DSL do
183
183
  http://jabber.org/protocol/muc
184
184
  }
185
185
  @dsl.set_caps node, identities, features
186
- @client.caps.node.should == "#{node}##{@client.caps.ver}"
187
- @client.caps.identities.should == identities
188
- @client.caps.features.map{ |f| f.var }.should == features
186
+ expect(@client.caps.node).to eq("#{node}##{@client.caps.ver}")
187
+ expect(@client.caps.identities).to eq(identities)
188
+ expect(@client.caps.features.map{ |f| f.var }).to eq(features)
189
189
  end
190
190
 
191
191
  it 'provides a caps send helper' do
192
- @dsl.should respond_to :send_caps
192
+ expect(@dsl).to respond_to :send_caps
193
193
  @client.caps.node = 'http://code.google.com/p/exodus'
194
194
  @client.caps.identities = [Blather::Stanza::Iq::DiscoInfo::Identity.new({:name => 'Exodus 0.9.1', :type => 'pc', :category => 'client'})]
195
195
  @client.caps.features = %w{
@@ -260,8 +260,8 @@ describe Blather::DSL do
260
260
  it 'has a pubsub helper set to the jid domain' do
261
261
  jid = Blather::JID.new('jid@domain/resource')
262
262
  @client.stubs(:jid).returns jid
263
- @dsl.pubsub.should be_instance_of Blather::DSL::PubSub
264
- @dsl.pubsub.host.should == jid.domain
263
+ expect(@dsl.pubsub).to be_instance_of Blather::DSL::PubSub
264
+ expect(@dsl.pubsub.host).to eq(jid.domain)
265
265
  end
266
266
 
267
267
  context "extending a module" do
@@ -291,7 +291,7 @@ describe Blather::DSL do
291
291
 
292
292
  it "should override the handlers" do
293
293
  target = CollisionTarget.new
294
- target.presence.should be :ghostly
294
+ expect(target.presence).to be :ghostly
295
295
  end
296
296
  end
297
297
  end
@@ -10,9 +10,9 @@ end
10
10
 
11
11
  describe Blather::SASLError do
12
12
  it 'can import a node' do
13
- Blather::SASLError.should respond_to :import
13
+ expect(Blather::SASLError).to respond_to :import
14
14
  e = Blather::SASLError.import sasl_error_node
15
- e.should be_kind_of Blather::SASLError
15
+ expect(e).to be_kind_of Blather::SASLError
16
16
  end
17
17
 
18
18
  describe 'each XMPP SASL error type' do
@@ -26,7 +26,7 @@ describe Blather::SASLError do
26
26
  ].each do |error_type|
27
27
  it "handles the name for #{error_type}" do
28
28
  e = Blather::SASLError.import sasl_error_node(error_type)
29
- e.name.should == error_type.gsub('-','_').to_sym
29
+ expect(e.name).to eq(error_type.gsub('-','_').to_sym)
30
30
  end
31
31
  end
32
32
  end
@@ -24,20 +24,20 @@ end
24
24
 
25
25
  describe Blather::StanzaError do
26
26
  it 'can import a node' do
27
- Blather::StanzaError.should respond_to :import
27
+ expect(Blather::StanzaError).to respond_to :import
28
28
  e = Blather::StanzaError.import stanza_error_node
29
- e.should be_kind_of Blather::StanzaError
29
+ expect(e).to be_kind_of Blather::StanzaError
30
30
  end
31
31
 
32
32
  describe 'valid types' do
33
33
  before { @original = Blather::Stanza::Message.new 'error@jabber.local', 'test message', :error }
34
34
 
35
35
  it 'ensures type is one of Stanza::Message::VALID_TYPES' do
36
- lambda { Blather::StanzaError.new @original, :gone, :invalid_type_name }.should raise_error(Blather::ArgumentError)
36
+ expect { Blather::StanzaError.new @original, :gone, :invalid_type_name }.to raise_error(Blather::ArgumentError)
37
37
 
38
38
  Blather::StanzaError::VALID_TYPES.each do |valid_type|
39
39
  msg = Blather::StanzaError.new @original, :gone, valid_type
40
- msg.type.should == valid_type
40
+ expect(msg.type).to eq(valid_type)
41
41
  end
42
42
  end
43
43
  end
@@ -51,48 +51,48 @@ describe Blather::StanzaError do
51
51
  end
52
52
 
53
53
  it 'provides a type attribute' do
54
- @err.should respond_to :type
55
- @err.type.should == @type.to_sym
54
+ expect(@err).to respond_to :type
55
+ expect(@err.type).to eq(@type.to_sym)
56
56
  end
57
57
 
58
58
  it 'provides a name attribute' do
59
- @err.should respond_to :name
60
- @err.name.should == @err_name.gsub('-','_').to_sym
59
+ expect(@err).to respond_to :name
60
+ expect(@err.name).to eq(@err_name.gsub('-','_').to_sym)
61
61
  end
62
62
 
63
63
  it 'provides a text attribute' do
64
- @err.should respond_to :text
65
- @err.text.should == @msg
64
+ expect(@err).to respond_to :text
65
+ expect(@err.text).to eq(@msg)
66
66
  end
67
67
 
68
68
  it 'provides a reader to the original node' do
69
- @err.should respond_to :original
70
- @err.original.should be_instance_of Blather::Stanza::Message
69
+ expect(@err).to respond_to :original
70
+ expect(@err.original).to be_instance_of Blather::Stanza::Message
71
71
  end
72
72
 
73
73
  it 'provides an extras attribute' do
74
- @err.should respond_to :extras
75
- @err.extras.should be_instance_of Array
76
- @err.extras.first.element_name.should == 'extra-error'
74
+ expect(@err).to respond_to :extras
75
+ expect(@err.extras).to be_instance_of Array
76
+ expect(@err.extras.first.element_name).to eq('extra-error')
77
77
  end
78
78
 
79
79
  it 'describes itself' do
80
- @err.to_s.should match(/#{@err_name}/)
81
- @err.to_s.should match(/#{@msg}/)
80
+ expect(@err.to_s).to match(/#{@err_name}/)
81
+ expect(@err.to_s).to match(/#{@msg}/)
82
82
 
83
- @err.inspect.should match(/#{@err_name}/)
84
- @err.inspect.should match(/#{@msg}/)
83
+ expect(@err.inspect).to match(/#{@err_name}/)
84
+ expect(@err.inspect).to match(/#{@msg}/)
85
85
  end
86
86
 
87
87
  it 'can be turned into xml' do
88
- @err.should respond_to :to_xml
88
+ expect(@err).to respond_to :to_xml
89
89
  doc = parse_stanza @err.to_xml
90
90
 
91
- doc.xpath("/message[@from='error@jabber.local' and @type='error']").should_not be_empty
92
- doc.xpath("/message/error").should_not be_empty
93
- doc.xpath("/message/error/err_ns:internal-server-error", :err_ns => Blather::StanzaError::STANZA_ERR_NS).should_not be_empty
94
- doc.xpath("/message/error/err_ns:text[.='the server has experienced a misconfiguration']", :err_ns => Blather::StanzaError::STANZA_ERR_NS).should_not be_empty
95
- doc.xpath("/message/error/extra_ns:extra-error[.='Blather Error']", :extra_ns => 'blather:stanza:error').should_not be_empty
91
+ expect(doc.xpath("/message[@from='error@jabber.local' and @type='error']")).not_to be_empty
92
+ expect(doc.xpath("/message/error")).not_to be_empty
93
+ expect(doc.xpath("/message/error/err_ns:internal-server-error", :err_ns => Blather::StanzaError::STANZA_ERR_NS)).not_to be_empty
94
+ expect(doc.xpath("/message/error/err_ns:text[.='the server has experienced a misconfiguration']", :err_ns => Blather::StanzaError::STANZA_ERR_NS)).not_to be_empty
95
+ expect(doc.xpath("/message/error/extra_ns:extra-error[.='Blather Error']", :extra_ns => 'blather:stanza:error')).not_to be_empty
96
96
  end
97
97
  end
98
98
 
@@ -122,7 +122,7 @@ describe Blather::StanzaError do
122
122
  ].each do |error_type|
123
123
  it "handles the name for #{error_type}" do
124
124
  e = Blather::StanzaError.import stanza_error_node(:cancel, error_type)
125
- e.name.should == error_type.gsub('-','_').to_sym
125
+ expect(e.name).to eq(error_type.gsub('-','_').to_sym)
126
126
  end
127
127
  end
128
128
  end
@@ -23,13 +23,13 @@ end
23
23
  describe 'Blather::StreamError' do
24
24
  it 'can import a node' do
25
25
  err = stream_error_node 'internal-server-error', 'the message'
26
- Blather::StreamError.should respond_to :import
26
+ expect(Blather::StreamError).to respond_to :import
27
27
  e = Blather::StreamError.import err
28
- e.should be_kind_of Blather::StreamError
28
+ expect(e).to be_kind_of Blather::StreamError
29
29
 
30
- e.name.should == :internal_server_error
31
- e.text.should == 'the message'
32
- e.extras.should == err.find('descendant::*[name()="extra-error"]', 'blather:stream:error').map {|n|n}
30
+ expect(e.name).to eq(:internal_server_error)
31
+ expect(e.text).to eq('the message')
32
+ expect(e.extras).to eq(err.find('descendant::*[name()="extra-error"]', 'blather:stream:error').map {|n|n})
33
33
  end
34
34
  end
35
35
 
@@ -41,36 +41,36 @@ describe 'Blather::StreamError when instantiated' do
41
41
  end
42
42
 
43
43
  it 'provides a err_name attribute' do
44
- @err.should respond_to :name
45
- @err.name.should == @err_name.gsub('-','_').to_sym
44
+ expect(@err).to respond_to :name
45
+ expect(@err.name).to eq(@err_name.gsub('-','_').to_sym)
46
46
  end
47
47
 
48
48
  it 'provides a text attribute' do
49
- @err.should respond_to :text
50
- @err.text.should == @msg
49
+ expect(@err).to respond_to :text
50
+ expect(@err.text).to eq(@msg)
51
51
  end
52
52
 
53
53
  it 'provides an extras attribute' do
54
- @err.should respond_to :extras
55
- @err.extras.should be_instance_of Array
56
- @err.extras.size.should == 1
57
- @err.extras.first.element_name.should == 'extra-error'
54
+ expect(@err).to respond_to :extras
55
+ expect(@err.extras).to be_instance_of Array
56
+ expect(@err.extras.size).to eq(1)
57
+ expect(@err.extras.first.element_name).to eq('extra-error')
58
58
  end
59
59
 
60
60
  it 'describes itself' do
61
- @err.to_s.should match(/#{@type}/)
62
- @err.to_s.should match(/#{@msg}/)
61
+ expect(@err.to_s).to match(/#{@type}/)
62
+ expect(@err.to_s).to match(/#{@msg}/)
63
63
 
64
- @err.inspect.should match(/#{@type}/)
65
- @err.inspect.should match(/#{@msg}/)
64
+ expect(@err.inspect).to match(/#{@type}/)
65
+ expect(@err.inspect).to match(/#{@msg}/)
66
66
  end
67
67
 
68
68
  it 'can be turned into xml' do
69
- @err.should respond_to :to_xml
69
+ expect(@err).to respond_to :to_xml
70
70
  doc = parse_stanza @err.to_xml
71
- doc.xpath("//err_ns:internal-server-error", :err_ns => Blather::StreamError::STREAM_ERR_NS).should_not be_empty
72
- doc.xpath("//err_ns:text[.='the server has experienced a misconfiguration']", :err_ns => Blather::StreamError::STREAM_ERR_NS).should_not be_empty
73
- doc.xpath("//err_ns:extra-error[.='Blather Error']", :err_ns => 'blather:stream:error').should_not be_empty
71
+ expect(doc.xpath("//err_ns:internal-server-error", :err_ns => Blather::StreamError::STREAM_ERR_NS)).not_to be_empty
72
+ expect(doc.xpath("//err_ns:text[.='the server has experienced a misconfiguration']", :err_ns => Blather::StreamError::STREAM_ERR_NS)).not_to be_empty
73
+ expect(doc.xpath("//err_ns:extra-error[.='Blather Error']", :err_ns => 'blather:stream:error')).not_to be_empty
74
74
  end
75
75
  end
76
76
 
@@ -102,7 +102,7 @@ describe 'Each XMPP stream error type' do
102
102
  ].each do |error_type|
103
103
  it "handles the name for #{error_type}" do
104
104
  e = Blather::StreamError.import stream_error_node(error_type)
105
- e.name.should == error_type.gsub('-','_').to_sym
105
+ expect(e.name).to eq(error_type.gsub('-','_').to_sym)
106
106
  end
107
107
  end
108
108
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Blather::BlatherError do
4
4
  it 'is handled by :error' do
5
- Blather::BlatherError.new.handler_hierarchy.should == [:error]
5
+ expect(Blather::BlatherError.new.handler_hierarchy).to eq([:error])
6
6
  end
7
7
  end
8
8
 
@@ -10,12 +10,12 @@ describe 'Blather::ParseError' do
10
10
  before { @error = Blather::ParseError.new('</generate-parse-error>"') }
11
11
 
12
12
  it 'is registers with the handler hierarchy' do
13
- @error.handler_hierarchy.should == [:parse_error, :error]
13
+ expect(@error.handler_hierarchy).to eq([:parse_error, :error])
14
14
  end
15
15
 
16
16
  it 'contains the error message' do
17
- @error.should respond_to :message
18
- @error.message.should == '</generate-parse-error>"'
17
+ expect(@error).to respond_to :message
18
+ expect(@error.message).to eq('</generate-parse-error>"')
19
19
  end
20
20
  end
21
21
 
@@ -23,11 +23,11 @@ describe 'Blather::UnknownResponse' do
23
23
  before { @error = Blather::UnknownResponse.new(Blather::XMPPNode.new('foo-bar')) }
24
24
 
25
25
  it 'is registers with the handler hierarchy' do
26
- @error.handler_hierarchy.should == [:unknown_response_error, :error]
26
+ expect(@error.handler_hierarchy).to eq([:unknown_response_error, :error])
27
27
  end
28
28
 
29
29
  it 'holds on to a copy of the failure node' do
30
- @error.should respond_to :node
31
- @error.node.element_name.should == 'foo-bar'
30
+ expect(@error).to respond_to :node
31
+ expect(@error.node.element_name).to eq('foo-bar')
32
32
  end
33
33
  end
@@ -47,7 +47,7 @@ describe Blather::FileTransfer do
47
47
  iq = Blather::XMPPNode.parse(si_xml)
48
48
 
49
49
  @client.stubs(:write).with do |answer|
50
- answer.si.feature.x.field('stream-method').value.should == Blather::Stanza::Iq::Ibb::NS_IBB
50
+ expect(answer.si.feature.x.field('stream-method').value).to eq(Blather::Stanza::Iq::Ibb::NS_IBB)
51
51
  true
52
52
  end
53
53
 
@@ -61,7 +61,7 @@ describe Blather::FileTransfer do
61
61
  iq = Blather::XMPPNode.parse(si_xml)
62
62
 
63
63
  @client.stubs(:write).with do |answer|
64
- answer.si.feature.x.field('stream-method').value.should == Blather::Stanza::Iq::S5b::NS_S5B
64
+ expect(answer.si.feature.x.field('stream-method').value).to eq(Blather::Stanza::Iq::S5b::NS_S5B)
65
65
  true
66
66
  end
67
67
 
@@ -75,7 +75,7 @@ describe Blather::FileTransfer do
75
75
  iq = Blather::XMPPNode.parse(si_xml)
76
76
 
77
77
  @client.stubs(:write).with do |answer|
78
- answer.si.feature.x.field('stream-method').value.should == Blather::Stanza::Iq::S5b::NS_S5B
78
+ expect(answer.si.feature.x.field('stream-method').value).to eq(Blather::Stanza::Iq::S5b::NS_S5B)
79
79
  true
80
80
  end
81
81
 
@@ -90,8 +90,8 @@ describe Blather::FileTransfer do
90
90
  iq = Blather::XMPPNode.parse(si_xml)
91
91
 
92
92
  @client.stubs(:write).with do |answer|
93
- answer.find_first('error')['type'].should == "cancel"
94
- answer.find_first('.//ns:no-valid-streams', :ns => 'http://jabber.org/protocol/si').should_not be_nil
93
+ expect(answer.find_first('error')['type']).to eq("cancel")
94
+ expect(answer.find_first('.//ns:no-valid-streams', :ns => 'http://jabber.org/protocol/si')).not_to be_nil
95
95
  true
96
96
  end
97
97
 
@@ -105,9 +105,9 @@ describe Blather::FileTransfer do
105
105
  iq = Blather::XMPPNode.parse(si_xml)
106
106
 
107
107
  @client.stubs(:write).with do |answer|
108
- answer.find_first('error')['type'].should == "cancel"
109
- answer.find_first('.//ns:forbidden', :ns => 'urn:ietf:params:xml:ns:xmpp-stanzas').should_not be_nil
110
- answer.find_first('.//ns:text', :ns => 'urn:ietf:params:xml:ns:xmpp-stanzas').content.should == "Offer declined"
108
+ expect(answer.find_first('error')['type']).to eq("cancel")
109
+ expect(answer.find_first('.//ns:forbidden', :ns => 'urn:ietf:params:xml:ns:xmpp-stanzas')).not_to be_nil
110
+ expect(answer.find_first('.//ns:text', :ns => 'urn:ietf:params:xml:ns:xmpp-stanzas').content).to eq("Offer declined")
111
111
  true
112
112
  end
113
113
 
@@ -130,6 +130,6 @@ describe Blather::FileTransfer do
130
130
  end
131
131
  end
132
132
  end
133
- lambda { TestS5B.new }.should_not raise_error
133
+ expect { TestS5B.new }.not_to raise_error
134
134
  end
135
135
  end
@@ -3,85 +3,85 @@ require 'spec_helper'
3
3
  describe Blather::JID do
4
4
  it 'does nothing if creaded from Blather::JID' do
5
5
  jid = Blather::JID.new 'n@d/r'
6
- Blather::JID.new(jid).object_id.should == jid.object_id
6
+ expect(Blather::JID.new(jid).object_id).to eq(jid.object_id)
7
7
  end
8
8
 
9
9
  it 'creates a new Blather::JID from (n,d,r)' do
10
10
  jid = Blather::JID.new('n', 'd', 'r')
11
- jid.node.should == 'n'
12
- jid.domain.should == 'd'
13
- jid.resource.should == 'r'
11
+ expect(jid.node).to eq('n')
12
+ expect(jid.domain).to eq('d')
13
+ expect(jid.resource).to eq('r')
14
14
  end
15
15
 
16
16
  it 'creates a new Blather::JID from (n,d)' do
17
17
  jid = Blather::JID.new('n', 'd')
18
- jid.node.should == 'n'
19
- jid.domain.should == 'd'
18
+ expect(jid.node).to eq('n')
19
+ expect(jid.domain).to eq('d')
20
20
  end
21
21
 
22
22
  it 'creates a new Blather::JID from (n@d)' do
23
23
  jid = Blather::JID.new('n@d')
24
- jid.node.should == 'n'
25
- jid.domain.should == 'd'
24
+ expect(jid.node).to eq('n')
25
+ expect(jid.domain).to eq('d')
26
26
  end
27
27
 
28
28
  it 'creates a new Blather::JID from (n@d/r)' do
29
29
  jid = Blather::JID.new('n@d/r')
30
- jid.node.should == 'n'
31
- jid.domain.should == 'd'
32
- jid.resource.should == 'r'
30
+ expect(jid.node).to eq('n')
31
+ expect(jid.domain).to eq('d')
32
+ expect(jid.resource).to eq('r')
33
33
  end
34
34
 
35
35
  it 'requires at least a node' do
36
- proc { Blather::JID.new }.should raise_error ::ArgumentError
36
+ expect { Blather::JID.new }.to raise_error ::ArgumentError
37
37
  end
38
38
 
39
39
  it 'ensures length of node is no more than 1023 characters' do
40
- proc { Blather::JID.new('n'*1024) }.should raise_error Blather::ArgumentError
40
+ expect { Blather::JID.new('n'*1024) }.to raise_error Blather::ArgumentError
41
41
  end
42
42
 
43
43
  it 'ensures length of domain is no more than 1023 characters' do
44
- proc { Blather::JID.new('n', 'd'*1024) }.should raise_error Blather::ArgumentError
44
+ expect { Blather::JID.new('n', 'd'*1024) }.to raise_error Blather::ArgumentError
45
45
  end
46
46
 
47
47
  it 'ensures length of resource is no more than 1023 characters' do
48
- proc { Blather::JID.new('n', 'd', 'r'*1024) }.should raise_error Blather::ArgumentError
48
+ expect { Blather::JID.new('n', 'd', 'r'*1024) }.to raise_error Blather::ArgumentError
49
49
  end
50
50
 
51
51
  it 'compares Blather::JIDs' do
52
- (Blather::JID.new('a@b/c') <=> Blather::JID.new('d@e/f')).should == -1
53
- (Blather::JID.new('a@b/c') <=> Blather::JID.new('a@b/c')).should == 0
54
- (Blather::JID.new('d@e/f') <=> Blather::JID.new('a@b/c')).should == 1
52
+ expect(Blather::JID.new('a@b/c') <=> Blather::JID.new('d@e/f')).to eq(-1)
53
+ expect(Blather::JID.new('a@b/c') <=> Blather::JID.new('a@b/c')).to eq(0)
54
+ expect(Blather::JID.new('d@e/f') <=> Blather::JID.new('a@b/c')).to eq(1)
55
55
  end
56
56
 
57
57
  it 'checks for equality' do
58
- (Blather::JID.new('n@d/r') == Blather::JID.new('n@d/r')).should == true
59
- Blather::JID.new('n@d/r').eql?(Blather::JID.new('n@d/r')).should == true
58
+ expect(Blather::JID.new('n@d/r') == Blather::JID.new('n@d/r')).to eq(true)
59
+ expect(Blather::JID.new('n@d/r').eql?(Blather::JID.new('n@d/r'))).to eq(true)
60
60
  end
61
61
 
62
62
  it 'will strip' do
63
63
  jid = Blather::JID.new('n@d/r')
64
- jid.stripped.should == Blather::JID.new('n@d')
65
- jid.should == Blather::JID.new('n@d/r')
64
+ expect(jid.stripped).to eq(Blather::JID.new('n@d'))
65
+ expect(jid).to eq(Blather::JID.new('n@d/r'))
66
66
  end
67
67
 
68
68
  it 'will strip itself' do
69
69
  jid = Blather::JID.new('n@d/r')
70
70
  jid.strip!
71
- jid.should == Blather::JID.new('n@d')
71
+ expect(jid).to eq(Blather::JID.new('n@d'))
72
72
  end
73
73
 
74
74
  it 'has a string representation' do
75
- Blather::JID.new('n@d/r').to_s.should == 'n@d/r'
76
- Blather::JID.new('n', 'd', 'r').to_s.should == 'n@d/r'
77
- Blather::JID.new('n', 'd').to_s.should == 'n@d'
75
+ expect(Blather::JID.new('n@d/r').to_s).to eq('n@d/r')
76
+ expect(Blather::JID.new('n', 'd', 'r').to_s).to eq('n@d/r')
77
+ expect(Blather::JID.new('n', 'd').to_s).to eq('n@d')
78
78
  end
79
79
 
80
80
  it 'provides a #stripped? helper' do
81
81
  jid = Blather::JID.new 'a@b/c'
82
- jid.should respond_to :stripped?
83
- jid.stripped?.should_not equal true
82
+ expect(jid).to respond_to :stripped?
83
+ expect(jid.stripped?).not_to equal true
84
84
  jid.strip!
85
- jid.stripped?.should == true
85
+ expect(jid.stripped?).to eq(true)
86
86
  end
87
87
  end