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
@@ -3,72 +3,72 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSub::Unsubscribe do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:unsubscribe, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Unsubscribe
6
+ expect(Blather::XMPPNode.class_from_registration(:unsubscribe, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Unsubscribe)
7
7
  end
8
8
 
9
9
  it 'can be imported' do
10
- Blather::XMPPNode.parse(unsubscribe_xml).should be_instance_of Blather::Stanza::PubSub::Unsubscribe
10
+ expect(Blather::XMPPNode.parse(unsubscribe_xml)).to be_instance_of Blather::Stanza::PubSub::Unsubscribe
11
11
  end
12
12
 
13
13
  it 'ensures an unsubscribe node is present on create' do
14
14
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
15
- unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
15
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
16
16
  end
17
17
 
18
18
  it 'ensures an unsubscribe node exists when calling #unsubscribe' do
19
19
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
20
20
  unsubscribe.pubsub.remove_children :unsubscribe
21
- unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
21
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
22
22
 
23
- unsubscribe.unsubscribe.should_not be_nil
24
- unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
23
+ expect(unsubscribe.unsubscribe).not_to be_nil
24
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
25
25
  end
26
26
 
27
27
  it 'defaults to a set node' do
28
28
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node', 'jid'
29
- unsubscribe.type.should == :set
29
+ expect(unsubscribe.type).to eq(:set)
30
30
  end
31
31
 
32
32
  it 'sets the host if requested' do
33
33
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'pubsub.jabber.local', 'node', 'jid'
34
- unsubscribe.to.should == Blather::JID.new('pubsub.jabber.local')
34
+ expect(unsubscribe.to).to eq(Blather::JID.new('pubsub.jabber.local'))
35
35
  end
36
36
 
37
37
  it 'sets the node' do
38
38
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
39
- unsubscribe.node.should == 'node-name'
39
+ expect(unsubscribe.node).to eq('node-name')
40
40
  end
41
41
 
42
42
  it 'has a node attribute' do
43
43
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
44
- unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
45
- unsubscribe.node.should == 'node-name'
44
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
45
+ expect(unsubscribe.node).to eq('node-name')
46
46
 
47
47
  unsubscribe.node = 'new-node'
48
- unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
49
- unsubscribe.node.should == 'new-node'
48
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
49
+ expect(unsubscribe.node).to eq('new-node')
50
50
  end
51
51
 
52
52
  it 'has a jid attribute' do
53
53
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
54
- unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
55
- unsubscribe.jid.should == Blather::JID.new('jid')
54
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
55
+ expect(unsubscribe.jid).to eq(Blather::JID.new('jid'))
56
56
 
57
57
  unsubscribe.jid = Blather::JID.new('n@d/r')
58
- unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
59
- unsubscribe.jid.should == Blather::JID.new('n@d/r')
58
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
59
+ expect(unsubscribe.jid).to eq(Blather::JID.new('n@d/r'))
60
60
  end
61
61
 
62
62
  it 'has a subid attribute' do
63
63
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid'
64
- unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
64
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
65
65
 
66
66
  unsubscribe = Blather::Stanza::PubSub::Unsubscribe.new :set, 'host', 'node-name', 'jid', 'subid'
67
- unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
68
- unsubscribe.subid.should == 'subid'
67
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
68
+ expect(unsubscribe.subid).to eq('subid')
69
69
 
70
70
  unsubscribe.subid = 'newsubid'
71
- unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="newsubid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
72
- unsubscribe.subid.should == 'newsubid'
71
+ expect(unsubscribe.find('//ns:pubsub/ns:unsubscribe[@subid="newsubid"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
72
+ expect(unsubscribe.subid).to eq('newsubid')
73
73
  end
74
74
  end
@@ -3,11 +3,11 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSubOwner::Delete do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:delete, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner::Delete
6
+ expect(Blather::XMPPNode.class_from_registration(:delete, 'http://jabber.org/protocol/pubsub#owner')).to eq(Blather::Stanza::PubSubOwner::Delete)
7
7
  end
8
8
 
9
9
  it 'can be imported' do
10
- Blather::XMPPNode.parse(<<-NODE).should be_instance_of Blather::Stanza::PubSubOwner::Delete
10
+ expect(Blather::XMPPNode.parse(<<-NODE)).to be_instance_of Blather::Stanza::PubSubOwner::Delete
11
11
  <iq type='set'
12
12
  from='hamlet@denmark.lit/elsinore'
13
13
  to='pubsub.shakespeare.lit'
@@ -21,30 +21,30 @@ describe Blather::Stanza::PubSubOwner::Delete do
21
21
 
22
22
  it 'ensures an delete node is present on delete' do
23
23
  delete = Blather::Stanza::PubSubOwner::Delete.new
24
- delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
24
+ expect(delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_empty
25
25
  end
26
26
 
27
27
  it 'ensures an delete node exists when calling #delete_node' do
28
28
  delete = Blather::Stanza::PubSubOwner::Delete.new
29
29
  delete.pubsub.remove_children :delete
30
- delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_empty
30
+ expect(delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns)).to be_empty
31
31
 
32
- delete.delete_node.should_not be_nil
33
- delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
32
+ expect(delete.delete_node).not_to be_nil
33
+ expect(delete.find('//ns:pubsub/ns:delete', :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_empty
34
34
  end
35
35
 
36
36
  it 'defaults to a set node' do
37
37
  delete = Blather::Stanza::PubSubOwner::Delete.new
38
- delete.type.should == :set
38
+ expect(delete.type).to eq(:set)
39
39
  end
40
40
 
41
41
  it 'sets the host if requested' do
42
42
  delete = Blather::Stanza::PubSubOwner::Delete.new :set, 'pubsub.jabber.local'
43
- delete.to.should == Blather::JID.new('pubsub.jabber.local')
43
+ expect(delete.to).to eq(Blather::JID.new('pubsub.jabber.local'))
44
44
  end
45
45
 
46
46
  it 'sets the node' do
47
47
  delete = Blather::Stanza::PubSubOwner::Delete.new :set, 'host', 'node-name'
48
- delete.node.should == 'node-name'
48
+ expect(delete.node).to eq('node-name')
49
49
  end
50
50
  end
@@ -3,11 +3,11 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSubOwner::Purge do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:purge, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner::Purge
6
+ expect(Blather::XMPPNode.class_from_registration(:purge, 'http://jabber.org/protocol/pubsub#owner')).to eq(Blather::Stanza::PubSubOwner::Purge)
7
7
  end
8
8
 
9
9
  it 'can be imported' do
10
- Blather::XMPPNode.parse(<<-NODE).should be_instance_of Blather::Stanza::PubSubOwner::Purge
10
+ expect(Blather::XMPPNode.parse(<<-NODE)).to be_instance_of Blather::Stanza::PubSubOwner::Purge
11
11
  <iq type='set'
12
12
  from='hamlet@denmark.lit/elsinore'
13
13
  to='pubsub.shakespeare.lit'
@@ -21,30 +21,30 @@ describe Blather::Stanza::PubSubOwner::Purge do
21
21
 
22
22
  it 'ensures an purge node is present on create' do
23
23
  purge = Blather::Stanza::PubSubOwner::Purge.new
24
- purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
24
+ expect(purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_empty
25
25
  end
26
26
 
27
27
  it 'ensures an purge node exists when calling #purge_node' do
28
28
  purge = Blather::Stanza::PubSubOwner::Purge.new
29
29
  purge.pubsub.remove_children :purge
30
- purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_empty
30
+ expect(purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns)).to be_empty
31
31
 
32
- purge.purge_node.should_not be_nil
33
- purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_empty
32
+ expect(purge.purge_node).not_to be_nil
33
+ expect(purge.find('//ns:pubsub/ns:purge', :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_empty
34
34
  end
35
35
 
36
36
  it 'defaults to a set node' do
37
37
  purge = Blather::Stanza::PubSubOwner::Purge.new
38
- purge.type.should == :set
38
+ expect(purge.type).to eq(:set)
39
39
  end
40
40
 
41
41
  it 'sets the host if requested' do
42
42
  purge = Blather::Stanza::PubSubOwner::Purge.new :set, 'pubsub.jabber.local'
43
- purge.to.should == Blather::JID.new('pubsub.jabber.local')
43
+ expect(purge.to).to eq(Blather::JID.new('pubsub.jabber.local'))
44
44
  end
45
45
 
46
46
  it 'sets the node' do
47
47
  purge = Blather::Stanza::PubSubOwner::Purge.new :set, 'host', 'node-name'
48
- purge.node.should == 'node-name'
48
+ expect(purge.node).to eq('node-name')
49
49
  end
50
50
  end
@@ -3,25 +3,25 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSubOwner do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub#owner').should == Blather::Stanza::PubSubOwner
6
+ expect(Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub#owner')).to eq(Blather::Stanza::PubSubOwner)
7
7
  end
8
8
 
9
9
  it 'ensures a pubusb node is present on create' do
10
10
  pubsub = Blather::Stanza::PubSubOwner.new
11
- pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_nil
11
+ expect(pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_nil
12
12
  end
13
13
 
14
14
  it 'ensures a pubsub node exists when calling #pubsub' do
15
15
  pubsub = Blather::Stanza::PubSubOwner.new
16
16
  pubsub.remove_children :pubsub
17
- pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should be_nil
17
+ expect(pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns)).to be_nil
18
18
 
19
- pubsub.pubsub.should_not be_nil
20
- pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns).should_not be_nil
19
+ expect(pubsub.pubsub).not_to be_nil
20
+ expect(pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_nil
21
21
  end
22
22
 
23
23
  it 'sets the host if requested' do
24
24
  aff = Blather::Stanza::PubSubOwner.new :get, 'pubsub.jabber.local'
25
- aff.to.should == Blather::JID.new('pubsub.jabber.local')
25
+ expect(aff.to).to eq(Blather::JID.new('pubsub.jabber.local'))
26
26
  end
27
27
  end
@@ -3,31 +3,31 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSub do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub
6
+ expect(Blather::XMPPNode.class_from_registration(:pubsub, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub)
7
7
  end
8
8
 
9
9
  it 'ensures a pubusb node is present on create' do
10
10
  pubsub = Blather::Stanza::PubSub.new
11
- pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
11
+ expect(pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_nil
12
12
  end
13
13
 
14
14
  it 'ensures a pubsub node exists when calling #pubsub' do
15
15
  pubsub = Blather::Stanza::PubSub.new
16
16
  pubsub.remove_children :pubsub
17
- pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should be_nil
17
+ expect(pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns)).to be_nil
18
18
 
19
- pubsub.pubsub.should_not be_nil
20
- pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
19
+ expect(pubsub.pubsub).not_to be_nil
20
+ expect(pubsub.find_first('/iq/ns:pubsub', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_nil
21
21
  end
22
22
 
23
23
  it 'sets the host if requested' do
24
24
  aff = Blather::Stanza::PubSub.new :get, 'pubsub.jabber.local'
25
- aff.to.should == Blather::JID.new('pubsub.jabber.local')
25
+ expect(aff.to).to eq(Blather::JID.new('pubsub.jabber.local'))
26
26
  end
27
27
 
28
28
  it 'ensures newly inherited items are PubSubItem objects' do
29
29
  pubsub = Blather::XMPPNode.parse(items_all_nodes_xml)
30
- pubsub.items.map { |i| i.class }.uniq.should == [Blather::Stanza::PubSub::PubSubItem]
30
+ expect(pubsub.items.map { |i| i.class }.uniq).to eq([Blather::Stanza::PubSub::PubSubItem])
31
31
  end
32
32
  end
33
33
 
@@ -35,34 +35,34 @@ describe Blather::Stanza::PubSub::PubSubItem do
35
35
  it 'can be initialized with just an ID' do
36
36
  id = 'foobarbaz'
37
37
  item = Blather::Stanza::PubSub::Items::PubSubItem.new id
38
- item.id.should == id
38
+ expect(item.id).to eq(id)
39
39
  end
40
40
 
41
41
  it 'can be initialized with a payload' do
42
42
  payload = 'foobarbaz'
43
43
  item = Blather::Stanza::PubSub::Items::PubSubItem.new 'foo', payload
44
- item.payload.should == payload
44
+ expect(item.payload).to eq(payload)
45
45
  end
46
46
 
47
47
  it 'allows the payload to be set' do
48
48
  item = Blather::Stanza::PubSub::Items::PubSubItem.new
49
- item.payload.should be_nil
49
+ expect(item.payload).to be_nil
50
50
  item.payload = 'testing'
51
- item.payload.should == 'testing'
52
- item.content.should == 'testing'
51
+ expect(item.payload).to eq('testing')
52
+ expect(item.content).to eq('testing')
53
53
  end
54
54
 
55
55
  it 'allows the payload to be unset' do
56
56
  payload = 'foobarbaz'
57
57
  item = Blather::Stanza::PubSub::Items::PubSubItem.new 'foo', payload
58
- item.payload.should == payload
58
+ expect(item.payload).to eq(payload)
59
59
  item.payload = nil
60
- item.payload.should be_nil
60
+ expect(item.payload).to be_nil
61
61
  end
62
62
 
63
63
  it 'makes payloads readable as string' do
64
64
  payload = Blather::XMPPNode.new 'foo'
65
65
  item = Blather::Stanza::PubSub::Items::PubSubItem.new 'bar', payload
66
- item.payload.should == payload.to_s
66
+ expect(item.payload).to eq(payload.to_s)
67
67
  end
68
68
  end
@@ -32,60 +32,60 @@ describe Blather::Stanza::X do
32
32
 
33
33
  it 'can be created from an XML string' do
34
34
  x = Blather::Stanza::X.new parse_stanza(x_xml).root
35
- x.type.should == :form
36
- x.should be_instance_of Blather::Stanza::X
35
+ expect(x.type).to eq(:form)
36
+ expect(x).to be_instance_of Blather::Stanza::X
37
37
  end
38
38
 
39
39
  [:cancel, :form, :result, :submit].each do |type|
40
40
  it "type can be set as \"#{type}\"" do
41
41
  x = Blather::Stanza::X.new type
42
- x.type.should == type
42
+ expect(x.type).to eq(type)
43
43
  end
44
44
  end
45
45
 
46
46
  it 'is constructed properly' do
47
47
  n = Blather::Stanza::X.new :form
48
- n.find("/ns:x[@type='form']", :ns => Blather::Stanza::X.registered_ns).should_not be_empty
48
+ expect(n.find("/ns:x[@type='form']", :ns => Blather::Stanza::X.registered_ns)).not_to be_empty
49
49
  end
50
50
 
51
51
  it 'has an action attribute' do
52
52
  n = Blather::Stanza::X.new :form
53
- n.type.should == :form
53
+ expect(n.type).to eq(:form)
54
54
  n.type = :submit
55
- n.type.should == :submit
55
+ expect(n.type).to eq(:submit)
56
56
  end
57
57
 
58
58
  it 'has a title attribute' do
59
59
  n = Blather::Stanza::X.new :form
60
- n.title.should == nil
60
+ expect(n.title).to eq(nil)
61
61
  n.title = "Hello World!"
62
- n.title.should == "Hello World!"
62
+ expect(n.title).to eq("Hello World!")
63
63
  n.title = "goodbye"
64
- n.title.should == "goodbye"
64
+ expect(n.title).to eq("goodbye")
65
65
  end
66
66
 
67
67
  it 'has an instructions attribute' do
68
68
  n = Blather::Stanza::X.new :form
69
- n.instructions.should == nil
69
+ expect(n.instructions).to eq(nil)
70
70
  n.instructions = "Please fill in this form"
71
- n.instructions.should == "Please fill in this form"
71
+ expect(n.instructions).to eq("Please fill in this form")
72
72
  n.instructions = "goodbye"
73
- n.instructions.should == "goodbye"
73
+ expect(n.instructions).to eq("goodbye")
74
74
  end
75
75
 
76
76
  it 'inherits a list of fields' do
77
77
  n = Blather::Stanza::Iq::Command.new
78
78
  n.command << parse_stanza(x_xml).root
79
79
  r = Blather::Stanza::X.new.inherit n.form
80
- r.fields.size.should == 4
81
- r.fields.map { |f| f.class }.uniq.should == [Blather::Stanza::X::Field]
80
+ expect(r.fields.size).to eq(4)
81
+ expect(r.fields.map { |f| f.class }.uniq).to eq([Blather::Stanza::X::Field])
82
82
  end
83
83
 
84
84
  it 'returns a field object for a particular var' do
85
85
  x = Blather::Stanza::X.new parse_stanza(x_xml).root
86
86
  f = x.field 'field-name4'
87
- f.should be_instance_of Blather::Stanza::X::Field
88
- f.value.should == 'field-value4'
87
+ expect(f).to be_instance_of Blather::Stanza::X::Field
88
+ expect(f.value).to eq('field-value4')
89
89
  end
90
90
 
91
91
  it 'takes a list of hashes for fields' do
@@ -98,8 +98,8 @@ describe Blather::Stanza::X do
98
98
  Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
99
99
 
100
100
  di = Blather::Stanza::X.new nil, fields
101
- di.fields.size.should == 2
102
- di.fields.each { |f| control.include?(f).should == true }
101
+ expect(di.fields.size).to eq(2)
102
+ di.fields.each { |f| expect(control.include?(f)).to eq(true) }
103
103
  end
104
104
 
105
105
  it 'takes a list of Field objects as fields' do
@@ -107,8 +107,8 @@ describe Blather::Stanza::X do
107
107
  Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
108
108
 
109
109
  di = Blather::Stanza::X.new nil, control
110
- di.fields.size.should == 2
111
- di.fields.each { |f| control.include?(f).should == true }
110
+ expect(di.fields.size).to eq(2)
111
+ di.fields.each { |f| expect(control.include?(f)).to eq(true) }
112
112
  end
113
113
 
114
114
  it 'takes a mix of hashes and field objects as fields' do
@@ -121,17 +121,17 @@ describe Blather::Stanza::X do
121
121
  Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
122
122
 
123
123
  di = Blather::Stanza::X.new nil, fields
124
- di.fields.size.should == 2
125
- di.fields.each { |f| control.include?(f).should == true }
124
+ expect(di.fields.size).to eq(2)
125
+ di.fields.each { |f| expect(control.include?(f)).to eq(true) }
126
126
  end
127
127
 
128
128
  it 'allows adding of fields' do
129
129
  di = Blather::Stanza::X.new nil
130
- di.fields.size.should == 0
130
+ expect(di.fields.size).to eq(0)
131
131
  di.fields = [{:label => 'label', :type => 'text-single', :var => 'var', :required => true}]
132
- di.fields.size.should == 1
132
+ expect(di.fields.size).to eq(1)
133
133
  di.fields += [Blather::Stanza::X::Field.new(*%w[var1 text-single label1])]
134
- di.fields.size.should == 2
134
+ expect(di.fields.size).to eq(2)
135
135
  end
136
136
 
137
137
  end
@@ -140,76 +140,76 @@ describe Blather::Stanza::X::Field do
140
140
  subject { Blather::Stanza::X::Field.new nil }
141
141
 
142
142
  it "should have the namespace 'jabber:x:data'" do
143
- subject.namespace.href.should be == 'jabber:x:data'
143
+ expect(subject.namespace.href).to eq('jabber:x:data')
144
144
  end
145
145
 
146
146
  it 'will auto-inherit nodes' do
147
147
  n = parse_stanza "<field type='text-single' var='music' label='Music from the time of Shakespeare' />"
148
148
  i = Blather::Stanza::X::Field.new n.root
149
- i.type.should == 'text-single'
150
- i.var.should == 'music'
151
- i.label.should == 'Music from the time of Shakespeare'
149
+ expect(i.type).to eq('text-single')
150
+ expect(i.var).to eq('music')
151
+ expect(i.label).to eq('Music from the time of Shakespeare')
152
152
  end
153
153
 
154
154
  it 'has a type attribute' do
155
155
  n = Blather::Stanza::X::Field.new 'var', 'text-single'
156
- n.type.should == 'text-single'
156
+ expect(n.type).to eq('text-single')
157
157
  n.type = 'hidden'
158
- n.type.should == 'hidden'
158
+ expect(n.type).to eq('hidden')
159
159
  end
160
160
 
161
161
  it 'has a var attribute' do
162
162
  n = Blather::Stanza::X::Field.new 'name', 'text-single'
163
- n.var.should == 'name'
163
+ expect(n.var).to eq('name')
164
164
  n.var = 'email'
165
- n.var.should == 'email'
165
+ expect(n.var).to eq('email')
166
166
  end
167
167
 
168
168
  it 'has a label attribute' do
169
169
  n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
170
- n.label.should == 'Music from the time of Shakespeare'
170
+ expect(n.label).to eq('Music from the time of Shakespeare')
171
171
  n.label = 'Books by and about Shakespeare'
172
- n.label.should == 'Books by and about Shakespeare'
172
+ expect(n.label).to eq('Books by and about Shakespeare')
173
173
  end
174
174
 
175
175
  it 'has a desc attribute' do
176
176
  n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
177
- n.desc.should == nil
177
+ expect(n.desc).to eq(nil)
178
178
  n.desc = 'Books by and about Shakespeare'
179
- n.desc.should == 'Books by and about Shakespeare'
179
+ expect(n.desc).to eq('Books by and about Shakespeare')
180
180
  n.desc = 'goodbye'
181
- n.desc.should == 'goodbye'
181
+ expect(n.desc).to eq('goodbye')
182
182
  end
183
183
 
184
184
  it 'has a required? attribute' do
185
185
  n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
186
- n.required?.should == false
186
+ expect(n.required?).to eq(false)
187
187
  n.required = true
188
- n.required?.should == true
188
+ expect(n.required?).to eq(true)
189
189
  n.required = false
190
- n.required?.should == false
190
+ expect(n.required?).to eq(false)
191
191
  end
192
192
 
193
193
  it 'has a value attribute' do
194
194
  n = Blather::Stanza::X::Field.new 'subject', 'text-single', 'Music from the time of Shakespeare'
195
- n.value.should == nil
195
+ expect(n.value).to eq(nil)
196
196
  n.value = 'book1'
197
- n.value.should == 'book1'
197
+ expect(n.value).to eq('book1')
198
198
  n.value = 'book2'
199
- n.value.should == 'book2'
199
+ expect(n.value).to eq('book2')
200
200
  end
201
201
 
202
202
  it 'allows setting options' do
203
203
  di = Blather::Stanza::X::Field.new nil
204
- di.options.size.should == 0
204
+ expect(di.options.size).to eq(0)
205
205
  di.options = [{:label => 'Person', :value => 'person'}, Blather::Stanza::X::Field::Option.new(*%w[person1 Person1])]
206
- di.options.size.should == 2
206
+ expect(di.options.size).to eq(2)
207
207
  end
208
208
 
209
209
  it 'can determine equality' do
210
210
  a = Blather::Stanza::X::Field.new('subject', 'text-single')
211
- a.should == Blather::Stanza::X::Field.new('subject', 'text-single')
212
- a.should_not equal Blather::Stanza::X::Field.new('subject1', 'text-single')
211
+ expect(a).to eq(Blather::Stanza::X::Field.new('subject', 'text-single'))
212
+ expect(a).not_to equal Blather::Stanza::X::Field.new('subject1', 'text-single')
213
213
  end
214
214
  end
215
215
 
@@ -217,17 +217,17 @@ describe Blather::Stanza::X::Field::Option do
217
217
 
218
218
  it 'has a value attribute' do
219
219
  n = Blather::Stanza::X::Field::Option.new 'person1', 'Person 1'
220
- n.value.should == 'person1'
220
+ expect(n.value).to eq('person1')
221
221
  n.value = 'book1'
222
- n.value.should == 'book1'
222
+ expect(n.value).to eq('book1')
223
223
  end
224
224
 
225
225
  it 'has a label attribute' do
226
226
  n = Blather::Stanza::X::Field::Option.new 'person1', 'Person 1'
227
- n.label.should == 'Person 1'
227
+ expect(n.label).to eq('Person 1')
228
228
  n.label = 'Book 1'
229
- n.label.should == 'Book 1'
229
+ expect(n.label).to eq('Book 1')
230
230
  n.label = 'Book 2'
231
- n.label.should == 'Book 2'
231
+ expect(n.label).to eq('Book 2')
232
232
  end
233
233
  end