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
@@ -10,26 +10,26 @@ end
10
10
 
11
11
  describe Blather::Stanza::Iq::Ping do
12
12
  it 'registers itself' do
13
- Blather::XMPPNode.class_from_registration(:ping, 'urn:xmpp:ping').should == Blather::Stanza::Iq::Ping
13
+ expect(Blather::XMPPNode.class_from_registration(:ping, 'urn:xmpp:ping')).to eq(Blather::Stanza::Iq::Ping)
14
14
  end
15
15
 
16
16
  it 'can be imported' do
17
17
  node = Blather::XMPPNode.parse ping_xml
18
- node.should be_instance_of Blather::Stanza::Iq::Ping
18
+ expect(node).to be_instance_of Blather::Stanza::Iq::Ping
19
19
  end
20
20
 
21
21
  it 'ensures a ping node is present on create' do
22
22
  iq = Blather::Stanza::Iq::Ping.new
23
- iq.xpath('ns:ping', :ns => 'urn:xmpp:ping').should_not be_empty
23
+ expect(iq.xpath('ns:ping', :ns => 'urn:xmpp:ping')).not_to be_empty
24
24
  end
25
25
 
26
26
  it 'ensures a ping node exists when calling #ping' do
27
27
  iq = Blather::Stanza::Iq::Ping.new
28
28
  iq.ping.remove
29
- iq.xpath('ns:ping', :ns => 'urn:xmpp:ping').should be_empty
29
+ expect(iq.xpath('ns:ping', :ns => 'urn:xmpp:ping')).to be_empty
30
30
 
31
- iq.ping.should_not be_nil
32
- iq.xpath('ns:ping', :ns => 'urn:xmpp:ping').should_not be_empty
31
+ expect(iq.ping).not_to be_nil
32
+ expect(iq.xpath('ns:ping', :ns => 'urn:xmpp:ping')).not_to be_empty
33
33
  end
34
34
 
35
35
  it 'responds with an empty IQ' do
@@ -39,7 +39,7 @@ describe Blather::Stanza::Iq::Ping do
39
39
  pong.from = 'one@example.com'
40
40
  end
41
41
  reply = ping.reply
42
- reply.should == expected_pong
43
- reply.children.count.should == 0
42
+ expect(reply).to eq(expected_pong)
43
+ expect(reply.children.count).to eq(0)
44
44
  end
45
45
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Blather::Stanza::Iq::Query do
4
4
  it 'registers itself' do
5
- Blather::XMPPNode.class_from_registration(:query, nil).should == Blather::Stanza::Iq::Query
5
+ expect(Blather::XMPPNode.class_from_registration(:query, nil)).to eq(Blather::Stanza::Iq::Query)
6
6
  end
7
7
 
8
8
  it 'can be imported' do
@@ -13,52 +13,52 @@ describe Blather::Stanza::Iq::Query do
13
13
  </query>
14
14
  </iq>
15
15
  XML
16
- Blather::XMPPNode.parse(string).should be_instance_of Blather::Stanza::Iq::Query
16
+ expect(Blather::XMPPNode.parse(string)).to be_instance_of Blather::Stanza::Iq::Query
17
17
  end
18
18
 
19
19
  it 'ensures a query node is present on create' do
20
20
  query = Blather::Stanza::Iq::Query.new
21
- query.xpath('query').should_not be_empty
21
+ expect(query.xpath('query')).not_to be_empty
22
22
  end
23
23
 
24
24
  it 'ensures a query node exists when calling #query' do
25
25
  query = Blather::Stanza::Iq::Query.new
26
26
  query.remove_child :query
27
- query.xpath('query').should be_empty
27
+ expect(query.xpath('query')).to be_empty
28
28
 
29
- query.query.should_not be_nil
30
- query.xpath('query').should_not be_empty
29
+ expect(query.query).not_to be_nil
30
+ expect(query.xpath('query')).not_to be_empty
31
31
  end
32
32
 
33
33
  [:get, :set, :result, :error].each do |type|
34
34
  it "can be set as \"#{type}\"" do
35
35
  query = Blather::Stanza::Iq::Query.new type
36
- query.type.should == type
36
+ expect(query.type).to eq(type)
37
37
  end
38
38
  end
39
39
 
40
40
  it 'sets type to "result" on reply' do
41
41
  query = Blather::Stanza::Iq::Query.new
42
- query.type.should == :get
43
- reply = query.reply.type.should == :result
42
+ expect(query.type).to eq(:get)
43
+ reply = expect(query.reply.type).to eq(:result)
44
44
  end
45
45
 
46
46
  it 'sets type to "result" on reply!' do
47
47
  query = Blather::Stanza::Iq::Query.new
48
- query.type.should == :get
48
+ expect(query.type).to eq(:get)
49
49
  query.reply!
50
- query.type.should == :result
50
+ expect(query.type).to eq(:result)
51
51
  end
52
52
 
53
53
  it 'can be registered under a namespace' do
54
54
  class QueryNs < Blather::Stanza::Iq::Query; register :query_ns, nil, 'query:ns'; end
55
- Blather::XMPPNode.class_from_registration(:query, 'query:ns').should == QueryNs
55
+ expect(Blather::XMPPNode.class_from_registration(:query, 'query:ns')).to eq(QueryNs)
56
56
  query_ns = QueryNs.new
57
- query_ns.xpath('query').should be_empty
58
- query_ns.xpath('ns:query', :ns => 'query:ns').size.should == 1
57
+ expect(query_ns.xpath('query')).to be_empty
58
+ expect(query_ns.xpath('ns:query', :ns => 'query:ns').size).to eq(1)
59
59
 
60
60
  query_ns.query
61
61
  query_ns.query
62
- query_ns.xpath('ns:query', :ns => 'query:ns').size.should == 1
62
+ expect(query_ns.xpath('ns:query', :ns => 'query:ns').size).to eq(1)
63
63
  end
64
64
  end
@@ -26,17 +26,17 @@ end
26
26
 
27
27
  describe Blather::Stanza::Iq::Roster do
28
28
  it 'registers itself' do
29
- Blather::XMPPNode.class_from_registration(:query, 'jabber:iq:roster').should == Blather::Stanza::Iq::Roster
29
+ expect(Blather::XMPPNode.class_from_registration(:query, 'jabber:iq:roster')).to eq(Blather::Stanza::Iq::Roster)
30
30
  end
31
31
 
32
32
  it 'ensures newly inherited items are RosterItem objects' do
33
33
  n = parse_stanza roster_xml
34
34
  r = Blather::Stanza::Iq::Roster.new.inherit n.root
35
- r.items.map { |i| i.class }.uniq.should == [Blather::Stanza::Iq::Roster::RosterItem]
35
+ expect(r.items.map { |i| i.class }.uniq).to eq([Blather::Stanza::Iq::Roster::RosterItem])
36
36
  end
37
37
 
38
38
  it 'can be created with #import' do
39
- Blather::XMPPNode.parse(roster_xml).should be_instance_of Blather::Stanza::Iq::Roster
39
+ expect(Blather::XMPPNode.parse(roster_xml)).to be_instance_of Blather::Stanza::Iq::Roster
40
40
  end
41
41
 
42
42
  it 'retrieves version' do
@@ -49,22 +49,22 @@ end
49
49
  describe Blather::Stanza::Iq::Roster::RosterItem do
50
50
  it 'can be initialized with just a Blather::JID' do
51
51
  i = Blather::Stanza::Iq::Roster::RosterItem.new 'n@d/r'
52
- i.jid.should == Blather::JID.new('n@d/r').stripped
52
+ expect(i.jid).to eq(Blather::JID.new('n@d/r').stripped)
53
53
  end
54
54
 
55
55
  it 'can be initialized with a name' do
56
56
  i = Blather::Stanza::Iq::Roster::RosterItem.new nil, 'foobar'
57
- i.name.should == 'foobar'
57
+ expect(i.name).to eq('foobar')
58
58
  end
59
59
 
60
60
  it 'can be initialized with a subscription' do
61
61
  i = Blather::Stanza::Iq::Roster::RosterItem.new nil, nil, :both
62
- i.subscription.should == :both
62
+ expect(i.subscription).to eq(:both)
63
63
  end
64
64
 
65
65
  it 'can be initialized with ask (subscription sub-type)' do
66
66
  i = Blather::Stanza::Iq::Roster::RosterItem.new nil, nil, nil, :subscribe
67
- i.ask.should == :subscribe
67
+ expect(i.ask).to eq(:subscribe)
68
68
  end
69
69
 
70
70
  it 'can be initailized with a hash' do
@@ -73,10 +73,10 @@ describe Blather::Stanza::Iq::Roster::RosterItem do
73
73
  :subscription => :both,
74
74
  :ask => :subscribe }
75
75
  i = Blather::Stanza::Iq::Roster::RosterItem.new control
76
- i.jid.should == Blather::JID.new(control[:jid]).stripped
77
- i.name.should == control[:name]
78
- i.subscription.should == control[:subscription]
79
- i.ask.should == control[:ask]
76
+ expect(i.jid).to eq(Blather::JID.new(control[:jid]).stripped)
77
+ expect(i.name).to eq(control[:name])
78
+ expect(i.subscription).to eq(control[:subscription])
79
+ expect(i.ask).to eq(control[:ask])
80
80
  end
81
81
 
82
82
  it 'inherits a node when initialized with one' do
@@ -85,61 +85,61 @@ describe Blather::Stanza::Iq::Roster::RosterItem do
85
85
  n[:subscription] = 'both'
86
86
 
87
87
  i = Blather::Stanza::Iq::Roster::RosterItem.new n
88
- i.jid.should == Blather::JID.new('n@d/r')
89
- i.subscription.should == :both
88
+ expect(i.jid).to eq(Blather::JID.new('n@d/r'))
89
+ expect(i.subscription).to eq(:both)
90
90
  end
91
91
 
92
92
  it 'has a #groups helper that gives an array of groups' do
93
93
  n = parse_stanza "<item jid='romeo@example.net' subscription='both'><group>foo</group><group>bar</group><group>baz</group></item>"
94
94
  i = Blather::Stanza::Iq::Roster::RosterItem.new n.root
95
- i.should respond_to :groups
96
- i.groups.sort.should == %w[bar baz foo]
95
+ expect(i).to respond_to :groups
96
+ expect(i.groups.sort).to eq(%w[bar baz foo])
97
97
  end
98
98
 
99
99
  it 'has a helper to set the groups' do
100
100
  n = parse_stanza "<item jid='romeo@example.net' subscription='both'><group>foo</group><group>bar</group><group>baz</group></item>"
101
101
  i = Blather::Stanza::Iq::Roster::RosterItem.new n.root
102
- i.should respond_to :groups=
103
- i.groups.sort.should == %w[bar baz foo]
102
+ expect(i).to respond_to :groups=
103
+ expect(i.groups.sort).to eq(%w[bar baz foo])
104
104
  i.groups = %w[a b c]
105
- i.groups.sort.should == %w[a b c]
105
+ expect(i.groups.sort).to eq(%w[a b c])
106
106
  end
107
107
 
108
108
  it 'can be easily converted into a proper stanza' do
109
109
  xml = "<item jid='romeo@example.net' subscription='both'><group>foo</group><group>bar</group><group>baz</group></item>"
110
110
  n = parse_stanza xml
111
111
  i = Blather::Stanza::Iq::Roster::RosterItem.new n.root
112
- i.should respond_to :to_stanza
112
+ expect(i).to respond_to :to_stanza
113
113
  s = i.to_stanza
114
- s.should be_kind_of Blather::Stanza::Iq::Roster
115
- s.items.first.jid.should == Blather::JID.new('romeo@example.net')
116
- s.items.first.groups.sort.should == %w[bar baz foo]
114
+ expect(s).to be_kind_of Blather::Stanza::Iq::Roster
115
+ expect(s.items.first.jid).to eq(Blather::JID.new('romeo@example.net'))
116
+ expect(s.items.first.groups.sort).to eq(%w[bar baz foo])
117
117
  end
118
118
 
119
119
  it 'has an "attr_accessor" for jid' do
120
120
  i = Blather::Stanza::Iq::Roster::RosterItem.new
121
- i.should respond_to :jid
122
- i.jid.should be_nil
123
- i.should respond_to :jid=
121
+ expect(i).to respond_to :jid
122
+ expect(i.jid).to be_nil
123
+ expect(i).to respond_to :jid=
124
124
  i.jid = 'n@d/r'
125
- i.jid.should == Blather::JID.new('n@d/r').stripped
125
+ expect(i.jid).to eq(Blather::JID.new('n@d/r').stripped)
126
126
  end
127
127
 
128
128
  it 'has a name attribute' do
129
129
  i = Blather::Stanza::Iq::Roster::RosterItem.new
130
130
  i.name = 'name'
131
- i.name.should == 'name'
131
+ expect(i.name).to eq('name')
132
132
  end
133
133
 
134
134
  it 'has a subscription attribute' do
135
135
  i = Blather::Stanza::Iq::Roster::RosterItem.new
136
136
  i.subscription = :both
137
- i.subscription.should == :both
137
+ expect(i.subscription).to eq(:both)
138
138
  end
139
139
 
140
140
  it 'has an ask attribute' do
141
141
  i = Blather::Stanza::Iq::Roster::RosterItem.new
142
142
  i.ask = :subscribe
143
- i.ask.should == :subscribe
143
+ expect(i.ask).to eq(:subscribe)
144
144
  end
145
145
  end
@@ -23,35 +23,35 @@ end
23
23
 
24
24
  describe Blather::Stanza::Iq::S5b do
25
25
  it 'registers itself' do
26
- Blather::XMPPNode.class_from_registration(:query, 'http://jabber.org/protocol/bytestreams').should == Blather::Stanza::Iq::S5b
26
+ expect(Blather::XMPPNode.class_from_registration(:query, 'http://jabber.org/protocol/bytestreams')).to eq(Blather::Stanza::Iq::S5b)
27
27
  end
28
28
 
29
29
  it 'can be imported' do
30
30
  node = Blather::XMPPNode.parse s5b_open_xml
31
- node.should be_instance_of Blather::Stanza::Iq::S5b
31
+ expect(node).to be_instance_of Blather::Stanza::Iq::S5b
32
32
  end
33
33
 
34
34
  it 'can get sid' do
35
35
  node = Blather::XMPPNode.parse s5b_open_xml
36
- node.sid.should == 'vxf9n471bn46'
36
+ expect(node.sid).to eq('vxf9n471bn46')
37
37
  end
38
38
 
39
39
  it 'can get streamhosts' do
40
40
  node = Blather::XMPPNode.parse s5b_open_xml
41
- node.streamhosts.size.should == 2
41
+ expect(node.streamhosts.size).to eq(2)
42
42
  end
43
43
 
44
44
  it 'can set streamhosts' do
45
45
  node = Blather::Stanza::Iq::S5b.new
46
46
  node.streamhosts += [{:jid => 'test@example.com/foo', :host => '192.168.5.1', :port => 123}]
47
- node.streamhosts.size.should == 1
47
+ expect(node.streamhosts.size).to eq(1)
48
48
  node.streamhosts += [Blather::Stanza::Iq::S5b::StreamHost.new('test2@example.com/foo', '192.168.5.2', 123)]
49
- node.streamhosts.size.should == 2
49
+ expect(node.streamhosts.size).to eq(2)
50
50
  end
51
51
 
52
52
  it 'can get and set streamhost-used' do
53
53
  node = Blather::Stanza::Iq::S5b.new
54
54
  node.streamhost_used = 'used@example.com/foo'
55
- node.streamhost_used.jid.to_s.should == 'used@example.com/foo'
55
+ expect(node.streamhost_used.jid.to_s).to eq('used@example.com/foo')
56
56
  end
57
57
  end
@@ -27,27 +27,27 @@ end
27
27
 
28
28
  describe Blather::Stanza::Iq::Si do
29
29
  it 'registers itself' do
30
- Blather::XMPPNode.class_from_registration(:si, 'http://jabber.org/protocol/si').should == Blather::Stanza::Iq::Si
30
+ expect(Blather::XMPPNode.class_from_registration(:si, 'http://jabber.org/protocol/si')).to eq(Blather::Stanza::Iq::Si)
31
31
  end
32
32
 
33
33
  it 'can be imported' do
34
34
  node = Blather::XMPPNode.parse si_xml
35
- node.should be_instance_of Blather::Stanza::Iq::Si
36
- node.si.should be_instance_of Blather::Stanza::Iq::Si::Si
35
+ expect(node).to be_instance_of Blather::Stanza::Iq::Si
36
+ expect(node.si).to be_instance_of Blather::Stanza::Iq::Si::Si
37
37
  end
38
38
 
39
39
  it 'ensures a si node is present on create' do
40
40
  iq = Blather::Stanza::Iq::Si.new
41
- iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').should_not be_empty
41
+ expect(iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si')).not_to be_empty
42
42
  end
43
43
 
44
44
  it 'ensures a si node exists when calling #si' do
45
45
  iq = Blather::Stanza::Iq::Si.new
46
46
  iq.si.remove
47
- iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').should be_empty
47
+ expect(iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si')).to be_empty
48
48
 
49
- iq.si.should_not be_nil
50
- iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').should_not be_empty
49
+ expect(iq.si).not_to be_nil
50
+ expect(iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si')).not_to be_empty
51
51
  end
52
52
 
53
53
  it 'ensures a si node is replaced when calling #si=' do
@@ -58,8 +58,8 @@ describe Blather::Stanza::Iq::Si do
58
58
 
59
59
  iq.si = new_si
60
60
 
61
- iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').size.should == 1
62
- iq.si.id.should == 'a1'
61
+ expect(iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').size).to eq(1)
62
+ expect(iq.si.id).to eq('a1')
63
63
  end
64
64
  end
65
65
 
@@ -69,30 +69,30 @@ describe Blather::Stanza::Iq::Si::Si do
69
69
  si.id = 'a1'
70
70
  si.mime_type = 'text/plain'
71
71
  si.profile = 'http://jabber.org/protocol/si/profile/file-transfer'
72
- si.id.should == 'a1'
73
- si.mime_type.should == 'text/plain'
74
- si.profile.should == 'http://jabber.org/protocol/si/profile/file-transfer'
72
+ expect(si.id).to eq('a1')
73
+ expect(si.mime_type).to eq('text/plain')
74
+ expect(si.profile).to eq('http://jabber.org/protocol/si/profile/file-transfer')
75
75
  end
76
76
  end
77
77
 
78
78
  describe Blather::Stanza::Iq::Si::Si::File do
79
79
  it 'can be initialized with name and size' do
80
80
  file = Blather::Stanza::Iq::Si::Si::File.new('test.txt', 123)
81
- file.name.should == 'test.txt'
82
- file.size.should == 123
81
+ expect(file.name).to eq('test.txt')
82
+ expect(file.size).to eq(123)
83
83
  end
84
84
 
85
85
  it 'can be initialized with node' do
86
86
  node = Blather::XMPPNode.parse si_xml
87
87
 
88
88
  file = Blather::Stanza::Iq::Si::Si::File.new node.find_first('.//ns:file', :ns => 'http://jabber.org/protocol/si/profile/file-transfer')
89
- file.name.should == 'test.txt'
90
- file.size.should == 1022
89
+ expect(file.name).to eq('test.txt')
90
+ expect(file.size).to eq(1022)
91
91
  end
92
92
 
93
93
  it 'can set and get description' do
94
94
  file = Blather::Stanza::Iq::Si::Si::File.new('test.txt', 123)
95
95
  file.desc = 'This is a test. If this were a real file...'
96
- file.desc.should == 'This is a test. If this were a real file...'
96
+ expect(file.desc).to eq('This is a test. If this were a real file...')
97
97
  end
98
98
  end
@@ -12,27 +12,27 @@ end
12
12
 
13
13
  describe Blather::Stanza::Iq::Vcard do
14
14
  it 'registers itself' do
15
- Blather::XMPPNode.class_from_registration(:vCard, 'vcard-temp').should == Blather::Stanza::Iq::Vcard
15
+ expect(Blather::XMPPNode.class_from_registration(:vCard, 'vcard-temp')).to eq(Blather::Stanza::Iq::Vcard)
16
16
  end
17
17
 
18
18
  it 'can be imported' do
19
19
  query = Blather::XMPPNode.parse vcard_xml
20
- query.should be_instance_of Blather::Stanza::Iq::Vcard
21
- query.vcard.should be_instance_of Blather::Stanza::Iq::Vcard::Vcard
20
+ expect(query).to be_instance_of Blather::Stanza::Iq::Vcard
21
+ expect(query.vcard).to be_instance_of Blather::Stanza::Iq::Vcard::Vcard
22
22
  end
23
23
 
24
24
  it 'ensures a vcard node is present on create' do
25
25
  query = Blather::Stanza::Iq::Vcard.new
26
- query.xpath('ns:vCard', :ns => 'vcard-temp').should_not be_empty
26
+ expect(query.xpath('ns:vCard', :ns => 'vcard-temp')).not_to be_empty
27
27
  end
28
28
 
29
29
  it 'ensures a vcard node exists when calling #vcard' do
30
30
  query = Blather::Stanza::Iq::Vcard.new
31
31
  query.vcard.remove
32
- query.xpath('ns:vCard', :ns => 'vcard-temp').should be_empty
32
+ expect(query.xpath('ns:vCard', :ns => 'vcard-temp')).to be_empty
33
33
 
34
- query.vcard.should_not be_nil
35
- query.xpath('ns:vCard', :ns => 'vcard-temp').should_not be_empty
34
+ expect(query.vcard).not_to be_nil
35
+ expect(query.xpath('ns:vCard', :ns => 'vcard-temp')).not_to be_empty
36
36
  end
37
37
 
38
38
  it 'ensures a vcard node is replaced when calling #vcard=' do
@@ -43,8 +43,8 @@ describe Blather::Stanza::Iq::Vcard do
43
43
 
44
44
  query.vcard = new_vcard
45
45
 
46
- query.xpath('ns:vCard', :ns => 'vcard-temp').size.should == 1
47
- query.find_first('ns:vCard/ns:NICKNAME', :ns => 'vcard-temp').content.should == 'Mercutio'
46
+ expect(query.xpath('ns:vCard', :ns => 'vcard-temp').size).to eq(1)
47
+ expect(query.find_first('ns:vCard/ns:NICKNAME', :ns => 'vcard-temp').content).to eq('Mercutio')
48
48
  end
49
49
  end
50
50
 
@@ -52,42 +52,42 @@ describe Blather::Stanza::Iq::Vcard::Vcard do
52
52
  it 'can set vcard elements' do
53
53
  query = Blather::Stanza::Iq::Vcard.new :set
54
54
  query.vcard['NICKNAME'] = 'Romeo'
55
- query.find_first('ns:vCard/ns:NICKNAME', :ns => 'vcard-temp').content.should == 'Romeo'
55
+ expect(query.find_first('ns:vCard/ns:NICKNAME', :ns => 'vcard-temp').content).to eq('Romeo')
56
56
  end
57
57
 
58
58
  it 'can set deep vcard elements' do
59
59
  query = Blather::Stanza::Iq::Vcard.new :set
60
60
  query.vcard['PHOTO/TYPE'] = 'image/png'
61
61
  query.vcard['PHOTO/BINVAL'] = '===='
62
- query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.size.should == 2
63
- query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.detect { |n| n.element_name == 'TYPE' && n.content == 'image/png' }.should_not be_nil
64
- query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.detect { |n| n.element_name == 'BINVAL' && n.content == '====' }.should_not be_nil
62
+ expect(query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.size).to eq(2)
63
+ expect(query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.detect { |n| n.element_name == 'TYPE' && n.content == 'image/png' }).not_to be_nil
64
+ expect(query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.detect { |n| n.element_name == 'BINVAL' && n.content == '====' }).not_to be_nil
65
65
  end
66
66
 
67
67
  it 'can get vcard elements' do
68
68
  query = Blather::Stanza::Iq::Vcard.new :set
69
69
  query.vcard['NICKNAME'] = 'Romeo'
70
- query.vcard['NICKNAME'].should == 'Romeo'
70
+ expect(query.vcard['NICKNAME']).to eq('Romeo')
71
71
  end
72
72
 
73
73
  it 'can get deep vcard elements' do
74
74
  query = Blather::Stanza::Iq::Vcard.new :set
75
75
  query.vcard['PHOTO/TYPE'] = 'image/png'
76
76
  query.vcard['PHOTO/BINVAL'] = '===='
77
- query.vcard['PHOTO/TYPE'].should == 'image/png'
78
- query.vcard['PHOTO/BINVAL'].should == '===='
77
+ expect(query.vcard['PHOTO/TYPE']).to eq('image/png')
78
+ expect(query.vcard['PHOTO/BINVAL']).to eq('====')
79
79
  end
80
80
 
81
81
  it 'returns nil on vcard elements which does not exist' do
82
82
  query = Blather::Stanza::Iq::Vcard.new :set
83
83
  query.vcard['NICKNAME'] = 'Romeo'
84
- query.vcard['FN'].should be_nil
84
+ expect(query.vcard['FN']).to be_nil
85
85
  end
86
86
 
87
87
  it 'can update vcard elements' do
88
88
  query = Blather::XMPPNode.parse vcard_xml
89
- query.vcard['NICKNAME'].should == 'Romeo'
89
+ expect(query.vcard['NICKNAME']).to eq('Romeo')
90
90
  query.vcard['NICKNAME'] = 'Mercutio'
91
- query.vcard['NICKNAME'].should == 'Mercutio'
91
+ expect(query.vcard['NICKNAME']).to eq('Mercutio')
92
92
  end
93
93
  end