blather 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.rspec +3 -0
  2. data/.travis.yml +1 -8
  3. data/CHANGELOG.md +230 -0
  4. data/Guardfile +4 -4
  5. data/README.md +2 -8
  6. data/Rakefile +14 -27
  7. data/blather.gemspec +8 -18
  8. data/lib/blather.rb +1 -0
  9. data/lib/blather/client/client.rb +8 -0
  10. data/lib/blather/roster.rb +7 -0
  11. data/lib/blather/stanza/iq/roster.rb +1 -1
  12. data/lib/blather/stanza/message/muc_user.rb +2 -0
  13. data/lib/blather/stanza/muc/muc_user_base.rb +4 -3
  14. data/lib/blather/stanza/presence.rb +12 -14
  15. data/lib/blather/stanza/presence/c.rb +58 -62
  16. data/lib/blather/stanza/presence/muc.rb +14 -10
  17. data/lib/blather/stanza/presence/muc_user.rb +47 -36
  18. data/lib/blather/stanza/presence/status.rb +106 -101
  19. data/lib/blather/stanza/presence/subscription.rb +59 -60
  20. data/lib/blather/stream.rb +1 -3
  21. data/lib/blather/stream/features/resource.rb +0 -1
  22. data/lib/blather/version.rb +1 -2
  23. data/lib/blather/xmpp_node.rb +24 -3
  24. data/spec/blather/client/client_spec.rb +64 -64
  25. data/spec/blather/client/dsl/pubsub_spec.rb +127 -127
  26. data/spec/blather/client/dsl_spec.rb +11 -11
  27. data/spec/blather/errors/sasl_error_spec.rb +3 -3
  28. data/spec/blather/errors/stanza_error_spec.rb +26 -26
  29. data/spec/blather/errors/stream_error_spec.rb +22 -22
  30. data/spec/blather/errors_spec.rb +7 -7
  31. data/spec/blather/file_transfer_spec.rb +16 -18
  32. data/spec/blather/jid_spec.rb +29 -29
  33. data/spec/blather/roster_item_spec.rb +18 -18
  34. data/spec/blather/roster_spec.rb +18 -18
  35. data/spec/blather/stanza/discos/disco_info_spec.rb +56 -57
  36. data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
  37. data/spec/blather/stanza/iq/command_spec.rb +57 -57
  38. data/spec/blather/stanza/iq/ibb_spec.rb +27 -39
  39. data/spec/blather/stanza/iq/ping_spec.rb +13 -9
  40. data/spec/blather/stanza/iq/query_spec.rb +16 -16
  41. data/spec/blather/stanza/iq/roster_spec.rb +29 -30
  42. data/spec/blather/stanza/iq/s5b_spec.rb +10 -13
  43. data/spec/blather/stanza/iq/si_spec.rb +20 -23
  44. data/spec/blather/stanza/iq/vcard_spec.rb +22 -25
  45. data/spec/blather/stanza/iq_spec.rb +12 -12
  46. data/spec/blather/stanza/message/muc_user_spec.rb +36 -36
  47. data/spec/blather/stanza/message_spec.rb +56 -56
  48. data/spec/blather/stanza/presence/c_spec.rb +17 -7
  49. data/spec/blather/stanza/presence/muc_spec.rb +8 -8
  50. data/spec/blather/stanza/presence/muc_user_spec.rb +23 -23
  51. data/spec/blather/stanza/presence/status_spec.rb +42 -30
  52. data/spec/blather/stanza/presence/subscription_spec.rb +22 -23
  53. data/spec/blather/stanza/presence_spec.rb +72 -34
  54. data/spec/blather/stanza/pubsub/affiliations_spec.rb +12 -12
  55. data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
  56. data/spec/blather/stanza/pubsub/event_spec.rb +31 -31
  57. data/spec/blather/stanza/pubsub/items_spec.rb +21 -21
  58. data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
  59. data/spec/blather/stanza/pubsub/retract_spec.rb +20 -20
  60. data/spec/blather/stanza/pubsub/subscribe_spec.rb +17 -17
  61. data/spec/blather/stanza/pubsub/subscription_spec.rb +28 -28
  62. data/spec/blather/stanza/pubsub/subscriptions_spec.rb +11 -11
  63. data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +22 -22
  64. data/spec/blather/stanza/pubsub_owner/delete_spec.rb +9 -9
  65. data/spec/blather/stanza/pubsub_owner/purge_spec.rb +9 -9
  66. data/spec/blather/stanza/pubsub_owner_spec.rb +6 -6
  67. data/spec/blather/stanza/pubsub_spec.rb +16 -16
  68. data/spec/blather/stanza/x_spec.rb +53 -53
  69. data/spec/blather/stanza_spec.rb +39 -39
  70. data/spec/blather/stream/client_spec.rb +133 -133
  71. data/spec/blather/stream/component_spec.rb +7 -7
  72. data/spec/blather/stream/parser_spec.rb +24 -24
  73. data/spec/blather/stream/ssl_spec.rb +7 -7
  74. data/spec/blather/xmpp_node_spec.rb +17 -7
  75. data/spec/blather_spec.rb +4 -4
  76. data/spec/spec_helper.rb +6 -54
  77. metadata +53 -68
  78. data/CHANGELOG +0 -220
@@ -2,79 +2,117 @@ require 'spec_helper'
2
2
 
3
3
  describe Blather::Stanza::Presence do
4
4
  it 'registers itself' do
5
- Blather::XMPPNode.class_from_registration(:presence, nil).must_equal Blather::Stanza::Presence
5
+ Blather::XMPPNode.class_from_registration(:presence, nil).should == Blather::Stanza::Presence
6
6
  end
7
7
 
8
8
  it 'must be importable' do
9
- doc = parse_stanza '<presence type="probe"/>'
10
- Blather::XMPPNode.import(doc.root).must_be_instance_of Blather::Stanza::Presence
9
+ Blather::XMPPNode.parse('<presence type="probe"/>').should be_instance_of Blather::Stanza::Presence
11
10
  end
12
11
 
13
12
  it 'ensures type is one of Blather::Stanza::Presence::VALID_TYPES' do
14
13
  presence = Blather::Stanza::Presence.new
15
- lambda { presence.type = :invalid_type_name }.must_raise(Blather::ArgumentError)
14
+ lambda { presence.type = :invalid_type_name }.should raise_error(Blather::ArgumentError)
16
15
 
17
16
  Blather::Stanza::Presence::VALID_TYPES.each do |valid_type|
18
17
  presence.type = valid_type
19
- presence.type.must_equal valid_type
18
+ presence.type.should == valid_type
20
19
  end
21
20
  end
22
21
 
23
22
  Blather::Stanza::Presence::VALID_TYPES.each do |valid_type|
24
23
  it "provides a helper (#{valid_type}?) for type #{valid_type}" do
25
- Blather::Stanza::Presence.new.must_respond_to :"#{valid_type}?"
24
+ Blather::Stanza::Presence.new.should respond_to :"#{valid_type}?"
26
25
  end
27
26
 
28
27
  it "returns true on call to (#{valid_type}?) if type == #{valid_type}" do
29
28
  method = "#{valid_type}?".to_sym
30
29
  pres = Blather::Stanza::Presence.new
31
30
  pres.type = valid_type
32
- pres.must_respond_to method
33
- pres.__send__(method).must_equal true
31
+ pres.should respond_to method
32
+ pres.__send__(method).should == true
34
33
  end
35
34
  end
36
35
 
36
+ it 'creates a C object when importing a node with a c child' do
37
+ string = <<-XML
38
+ <presence from='bard@shakespeare.lit/globe'>
39
+ <c xmlns='http://jabber.org/protocol/caps'
40
+ hash='sha-1'
41
+ node='http://www.chatopus.com'
42
+ ver='zHyEOgxTrkpSdGcQKH8EFPLsriY='/>
43
+ </presence>
44
+ XML
45
+ s = Blather::Stanza::Presence.parse string
46
+ s.should be_kind_of Blather::Stanza::Presence::C::InstanceMethods
47
+ s.node.should == 'http://www.chatopus.com'
48
+ end
49
+
37
50
  it 'creates a Status object when importing a node with type == nil' do
38
- s = Blather::Stanza::Presence.import(parse_stanza('<presence/>').root)
39
- s.must_be_kind_of Blather::Stanza::Presence::Status
40
- s.state.must_equal :available
51
+ s = Blather::Stanza::Presence.parse('<presence/>')
52
+ s.should be_kind_of Blather::Stanza::Presence::Status::InstanceMethods
53
+ s.state.should == :available
41
54
  end
42
55
 
43
56
  it 'creates a Status object when importing a node with type == "unavailable"' do
44
- s = Blather::Stanza::Presence.import(parse_stanza('<presence type="unavailable"/>').root)
45
- s.must_be_kind_of Blather::Stanza::Presence::Status
46
- s.state.must_equal :unavailable
57
+ s = Blather::Stanza::Presence.parse('<presence type="unavailable"/>')
58
+ s.should be_kind_of Blather::Stanza::Presence::Status::InstanceMethods
59
+ s.state.should == :unavailable
47
60
  end
48
61
 
49
62
  it 'creates a Subscription object when importing a node with type == "subscribe"' do
50
- s = Blather::Stanza::Presence.import(parse_stanza('<presence type="subscribe"/>').root)
51
- s.must_be_kind_of Blather::Stanza::Presence::Subscription
52
- s.type.must_equal :subscribe
63
+ s = Blather::Stanza::Presence.parse('<presence type="subscribe"/>')
64
+ s.should be_kind_of Blather::Stanza::Presence::Subscription::InstanceMethods
65
+ s.type.should == :subscribe
53
66
  end
54
67
 
55
68
  it 'creates a MUC object when importing a node with a form in the MUC namespace' do
56
- n = Blather::XMPPNode.new
57
- x = Blather::XMPPNode.new 'x'
58
- x.namespace = "http://jabber.org/protocol/muc"
59
- n << x
60
- s = Blather::Stanza::Presence.import(n)
61
- s.must_be_kind_of Blather::Stanza::Presence::MUC
69
+ string = <<-XML
70
+ <presence from='bard@shakespeare.lit/globe'>
71
+ <x xmlns='http://jabber.org/protocol/muc'/>
72
+ </presence>
73
+ XML
74
+ s = Blather::Stanza::Presence.parse string
75
+ s.should be_kind_of Blather::Stanza::Presence::MUC::InstanceMethods
62
76
  end
63
77
 
64
78
  it 'creates a MUCUser object when importing a node with a form in the MUC#user namespace' do
65
- n = Blather::XMPPNode.new
66
- x = Blather::XMPPNode.new 'x'
67
- x.namespace = "http://jabber.org/protocol/muc#user"
68
- n << x
69
- s = Blather::Stanza::Presence.import(n)
70
- s.must_be_kind_of Blather::Stanza::Presence::MUCUser
79
+ string = <<-XML
80
+ <presence from='bard@shakespeare.lit/globe'>
81
+ <x xmlns='http://jabber.org/protocol/muc#user'/>
82
+ </presence>
83
+ XML
84
+ s = Blather::Stanza::Presence.parse string
85
+ s.should be_kind_of Blather::Stanza::Presence::MUCUser::InstanceMethods
71
86
  end
72
87
 
73
88
  it 'creates a Presence object when importing a node with type equal to something unknown' do
74
- n = Blather::XMPPNode.new
75
- n[:type] = :foo
76
- s = Blather::Stanza::Presence.import(n)
77
- s.must_be_kind_of Blather::Stanza::Presence
78
- s.type.must_equal :foo
89
+ string = "<presence from='bard@shakespeare.lit/globe' type='foo'/>"
90
+ s = Blather::Stanza::Presence.parse string
91
+ s.should be_kind_of Blather::Stanza::Presence
92
+ s.type.should == :foo
93
+ end
94
+
95
+ it 'behaves like a C, a Status, and a MUCUser when all types of children are present' do
96
+ string = <<-XML
97
+ <presence from='bard@shakespeare.lit/globe'>
98
+ <show>chat</show>
99
+ <c xmlns='http://jabber.org/protocol/caps'
100
+ hash='sha-1'
101
+ node='http://www.chatopus.com'
102
+ ver='zHyEOgxTrkpSdGcQKH8EFPLsriY='/>
103
+ <x xmlns='http://jabber.org/protocol/muc#user'>
104
+ <item affiliation='none'
105
+ jid='hag66@shakespeare.lit/pda'
106
+ role='participant'/>
107
+ <status code='100'/>
108
+ <status code='110'/>
109
+ <password>foobar</password>
110
+ </x>
111
+ </presence>
112
+ XML
113
+ s = Blather::Stanza::Presence.parse string
114
+ s.state.should == :chat
115
+ s.node.should == 'http://www.chatopus.com'
116
+ s.role.should == :participant
79
117
  end
80
118
  end
@@ -11,47 +11,47 @@ end
11
11
 
12
12
  describe Blather::Stanza::PubSub::Affiliations do
13
13
  it 'registers itself' do
14
- Blather::XMPPNode.class_from_registration(:affiliations, Blather::Stanza::PubSub.registered_ns).must_equal Blather::Stanza::PubSub::Affiliations
14
+ Blather::XMPPNode.class_from_registration(:affiliations, Blather::Stanza::PubSub.registered_ns).should == Blather::Stanza::PubSub::Affiliations
15
15
  end
16
16
 
17
17
  it 'can be imported' do
18
- Blather::XMPPNode.import(parse_stanza(affiliations_xml).root).must_be_instance_of Blather::Stanza::PubSub::Affiliations
18
+ Blather::XMPPNode.parse(affiliations_xml).should be_instance_of Blather::Stanza::PubSub::Affiliations
19
19
  end
20
20
 
21
21
  it 'ensures an affiliations node is present on create' do
22
22
  affiliations = Blather::Stanza::PubSub::Affiliations.new
23
- affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_nil
23
+ affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
24
24
  end
25
25
 
26
26
  it 'ensures an affiliations node exists when calling #affiliations' do
27
27
  affiliations = Blather::Stanza::PubSub::Affiliations.new
28
28
  affiliations.pubsub.remove_children :affiliations
29
- affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).must_be_nil
29
+ affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should be_nil
30
30
 
31
- affiliations.affiliations.wont_be_nil
32
- affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_nil
31
+ affiliations.affiliations.should_not be_nil
32
+ affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
33
33
  end
34
34
 
35
35
  it 'defaults to a get node' do
36
- Blather::Stanza::PubSub::Affiliations.new.type.must_equal :get
36
+ Blather::Stanza::PubSub::Affiliations.new.type.should == :get
37
37
  end
38
38
 
39
39
  it 'sets the host if requested' do
40
40
  aff = Blather::Stanza::PubSub::Affiliations.new :get, 'pubsub.jabber.local'
41
- aff.to.must_equal Blather::JID.new('pubsub.jabber.local')
41
+ aff.to.should == Blather::JID.new('pubsub.jabber.local')
42
42
  end
43
43
 
44
44
  it 'can import an affiliates result node' do
45
45
  node = parse_stanza(affiliations_xml).root
46
46
 
47
47
  affiliations = Blather::Stanza::PubSub::Affiliations.new.inherit node
48
- affiliations.size.must_equal 5
49
- affiliations.list.must_equal control_affiliations
48
+ affiliations.size.should == 5
49
+ affiliations.list.should == control_affiliations
50
50
  end
51
51
 
52
52
  it 'will iterate over each affiliation' do
53
- Blather::XMPPNode.import(parse_stanza(affiliations_xml).root).each do |type, nodes|
54
- nodes.must_equal control_affiliations[type]
53
+ Blather::XMPPNode.parse(affiliations_xml).each do |type, nodes|
54
+ nodes.should == control_affiliations[type]
55
55
  end
56
56
  end
57
57
  end
@@ -3,11 +3,11 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSub::Create do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:create, 'http://jabber.org/protocol/pubsub').must_equal Blather::Stanza::PubSub::Create
6
+ Blather::XMPPNode.class_from_registration(:create, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Create
7
7
  end
8
8
 
9
9
  it 'can be imported' do
10
- Blather::XMPPNode.import(parse_stanza(<<-NODE).root).must_be_instance_of Blather::Stanza::PubSub::Create
10
+ Blather::XMPPNode.parse(<<-NODE).should be_instance_of Blather::Stanza::PubSub::Create
11
11
  <iq type='set'
12
12
  from='hamlet@denmark.lit/elsinore'
13
13
  to='pubsub.shakespeare.lit'
@@ -22,35 +22,35 @@ describe Blather::Stanza::PubSub::Create do
22
22
 
23
23
  it 'ensures a create node is present on create' do
24
24
  create = Blather::Stanza::PubSub::Create.new
25
- create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
25
+ create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
26
26
  end
27
27
 
28
28
  it 'ensures a configure node is present on create' do
29
29
  create = Blather::Stanza::PubSub::Create.new
30
- create.find('//ns:pubsub/ns:configure', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
30
+ create.find('//ns:pubsub/ns:configure', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
31
31
  end
32
32
 
33
33
  it 'ensures a create node exists when calling #create_node' do
34
34
  create = Blather::Stanza::PubSub::Create.new
35
35
  create.pubsub.remove_children :create
36
- create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).must_be_empty
36
+ create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
37
37
 
38
- create.create_node.wont_be_nil
39
- create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
38
+ create.create_node.should_not be_nil
39
+ create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
40
40
  end
41
41
 
42
42
  it 'defaults to a set node' do
43
43
  create = Blather::Stanza::PubSub::Create.new
44
- create.type.must_equal :set
44
+ create.type.should == :set
45
45
  end
46
46
 
47
47
  it 'sets the host if requested' do
48
48
  create = Blather::Stanza::PubSub::Create.new :set, 'pubsub.jabber.local'
49
- create.to.must_equal Blather::JID.new('pubsub.jabber.local')
49
+ create.to.should == Blather::JID.new('pubsub.jabber.local')
50
50
  end
51
51
 
52
52
  it 'sets the node' do
53
53
  create = Blather::Stanza::PubSub::Create.new :set, 'host', 'node-name'
54
- create.node.must_equal 'node-name'
54
+ create.node.should == 'node-name'
55
55
  end
56
56
  end
@@ -3,60 +3,60 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSub::Event do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:event, 'http://jabber.org/protocol/pubsub#event').must_equal Blather::Stanza::PubSub::Event
6
+ Blather::XMPPNode.class_from_registration(:event, 'http://jabber.org/protocol/pubsub#event').should == Blather::Stanza::PubSub::Event
7
7
  end
8
8
 
9
9
  it 'is importable' do
10
- Blather::XMPPNode.import(parse_stanza(event_notification_xml).root).must_be_instance_of Blather::Stanza::PubSub::Event
10
+ Blather::XMPPNode.parse(event_notification_xml).should be_instance_of Blather::Stanza::PubSub::Event
11
11
  end
12
12
 
13
13
  it 'ensures a query node is present on create' do
14
14
  evt = Blather::Stanza::PubSub::Event.new
15
- evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns).wont_be_empty
15
+ evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns).should_not be_empty
16
16
  end
17
17
 
18
18
  it 'ensures an event node exists when calling #event_node' do
19
19
  evt = Blather::Stanza::PubSub::Event.new
20
20
  evt.remove_children :event
21
- evt.find('*[local-name()="event"]').must_be_empty
21
+ evt.find('*[local-name()="event"]').should be_empty
22
22
 
23
- evt.event_node.wont_be_nil
24
- evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns).wont_be_empty
23
+ evt.event_node.should_not be_nil
24
+ evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns).should_not be_empty
25
25
  end
26
26
 
27
27
  it 'ensures an items node exists when calling #items_node' do
28
28
  evt = Blather::Stanza::PubSub::Event.new
29
29
  evt.remove_children :items
30
- evt.find('*[local-name()="items"]').must_be_empty
30
+ evt.find('*[local-name()="items"]').should be_empty
31
31
 
32
- evt.items_node.wont_be_nil
33
- evt.find('ns:event/ns:items', :ns => Blather::Stanza::PubSub::Event.registered_ns).wont_be_empty
32
+ evt.items_node.should_not be_nil
33
+ evt.find('ns:event/ns:items', :ns => Blather::Stanza::PubSub::Event.registered_ns).should_not be_empty
34
34
  end
35
35
 
36
36
  it 'knows the associated node name' do
37
- evt = Blather::XMPPNode.import(parse_stanza(event_with_payload_xml).root)
38
- evt.node.must_equal 'princely_musings'
37
+ evt = Blather::XMPPNode.parse(event_with_payload_xml)
38
+ evt.node.should == 'princely_musings'
39
39
  end
40
40
 
41
41
  it 'ensures newly inherited items are PubSubItem objects' do
42
- evt = Blather::XMPPNode.import(parse_stanza(event_with_payload_xml).root)
43
- evt.items?.must_equal true
44
- evt.retractions?.must_equal false
45
- evt.items.map { |i| i.class }.uniq.must_equal [Blather::Stanza::PubSub::PubSubItem]
42
+ evt = Blather::XMPPNode.parse(event_with_payload_xml)
43
+ evt.items?.should == true
44
+ evt.retractions?.should == false
45
+ evt.items.map { |i| i.class }.uniq.should == [Blather::Stanza::PubSub::PubSubItem]
46
46
  end
47
47
 
48
48
  it 'will iterate over each item' do
49
- evt = Blather::XMPPNode.import(parse_stanza(event_with_payload_xml).root)
50
- evt.items.each { |i| i.class.must_equal Blather::Stanza::PubSub::PubSubItem }
49
+ evt = Blather::XMPPNode.parse(event_with_payload_xml)
50
+ evt.items.each { |i| i.class.should == Blather::Stanza::PubSub::PubSubItem }
51
51
  end
52
52
 
53
53
  it 'handles receiving subscription ids' do
54
- evt = Blather::XMPPNode.import(parse_stanza(event_subids_xml).root)
55
- evt.subscription_ids.must_equal ['123-abc', '004-yyy']
54
+ evt = Blather::XMPPNode.parse(event_subids_xml)
55
+ evt.subscription_ids.should == ['123-abc', '004-yyy']
56
56
  end
57
57
 
58
58
  it 'can have a list of retractions' do
59
- evt = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
59
+ evt = Blather::XMPPNode.parse(<<-NODE)
60
60
  <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
61
61
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
62
62
  <items node='princely_musings'>
@@ -65,34 +65,34 @@ describe Blather::Stanza::PubSub::Event do
65
65
  </event>
66
66
  </message>
67
67
  NODE
68
- evt.retractions?.must_equal true
69
- evt.items?.must_equal false
70
- evt.retractions.must_equal %w[ae890ac52d0df67ed7cfdf51b644e901]
68
+ evt.retractions?.should == true
69
+ evt.items?.should == false
70
+ evt.retractions.should == %w[ae890ac52d0df67ed7cfdf51b644e901]
71
71
  end
72
72
 
73
73
  it 'can be a purge' do
74
- evt = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
74
+ evt = Blather::XMPPNode.parse(<<-NODE)
75
75
  <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
76
76
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
77
77
  <purge node='princely_musings'/>
78
78
  </event>
79
79
  </message>
80
80
  NODE
81
- evt.purge?.wont_be_nil
82
- evt.node.must_equal 'princely_musings'
81
+ evt.purge?.should_not be_nil
82
+ evt.node.should == 'princely_musings'
83
83
  end
84
84
 
85
85
  it 'can be a subscription notification' do
86
- evt = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
86
+ evt = Blather::XMPPNode.parse(<<-NODE)
87
87
  <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
88
88
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
89
89
  <subscription jid='francisco@denmark.lit' subscription='subscribed' node='/example.com/test'/>
90
90
  </event>
91
91
  </message>
92
92
  NODE
93
- evt.subscription?.wont_be_nil
94
- evt.subscription[:jid].must_equal 'francisco@denmark.lit'
95
- evt.subscription[:subscription].must_equal 'subscribed'
96
- evt.subscription[:node].must_equal '/example.com/test'
93
+ evt.subscription?.should_not be_nil
94
+ evt.subscription[:jid].should == 'francisco@denmark.lit'
95
+ evt.subscription[:subscription].should == 'subscribed'
96
+ evt.subscription[:node].should == '/example.com/test'
97
97
  end
98
98
  end
@@ -3,43 +3,43 @@ require 'fixtures/pubsub'
3
3
 
4
4
  describe Blather::Stanza::PubSub::Items do
5
5
  it 'registers itself' do
6
- Blather::XMPPNode.class_from_registration(:items, 'http://jabber.org/protocol/pubsub').must_equal Blather::Stanza::PubSub::Items
6
+ Blather::XMPPNode.class_from_registration(:items, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Items
7
7
  end
8
8
 
9
9
  it 'can be imported' do
10
- Blather::XMPPNode.import(parse_stanza(items_all_nodes_xml).root).must_be_instance_of Blather::Stanza::PubSub::Items
10
+ Blather::XMPPNode.parse(items_all_nodes_xml).should be_instance_of Blather::Stanza::PubSub::Items
11
11
  end
12
12
 
13
13
  it 'ensures an items node is present on create' do
14
14
  items = Blather::Stanza::PubSub::Items.new
15
- items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
15
+ items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
16
16
  end
17
17
 
18
18
  it 'ensures an items node exists when calling #items' do
19
19
  items = Blather::Stanza::PubSub::Items.new
20
20
  items.pubsub.remove_children :items
21
- items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).must_be_empty
21
+ items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
22
22
 
23
- items.items.wont_be_nil
24
- items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).wont_be_empty
23
+ items.items.should_not be_nil
24
+ items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
25
25
  end
26
26
 
27
27
  it 'defaults to a get node' do
28
28
  aff = Blather::Stanza::PubSub::Items.new
29
- aff.type.must_equal :get
29
+ aff.type.should == :get
30
30
  end
31
31
 
32
32
  it 'ensures newly inherited items are PubSubItem objects' do
33
- items = Blather::XMPPNode.import(parse_stanza(items_all_nodes_xml).root)
34
- items.map { |i| i.class }.uniq.must_equal [Blather::Stanza::PubSub::PubSubItem]
33
+ items = Blather::XMPPNode.parse(items_all_nodes_xml)
34
+ items.map { |i| i.class }.uniq.should == [Blather::Stanza::PubSub::PubSubItem]
35
35
  end
36
36
 
37
37
  it 'will iterate over each item' do
38
38
  n = parse_stanza items_all_nodes_xml
39
39
  items = Blather::Stanza::PubSub::Items.new.inherit n.root
40
40
  count = 0
41
- items.each { |i| i.must_be_instance_of Blather::Stanza::PubSub::PubSubItem; count += 1 }
42
- count.must_equal 4
41
+ items.each { |i| i.should be_instance_of Blather::Stanza::PubSub::PubSubItem; count += 1 }
42
+ count.should == 4
43
43
  end
44
44
 
45
45
  it 'can create an items request node to request all items' do
@@ -47,9 +47,9 @@ describe Blather::Stanza::PubSub::Items do
47
47
  node = 'princely_musings'
48
48
 
49
49
  items = Blather::Stanza::PubSub::Items.request host, node
50
- items.find("//ns:items[@node=\"#{node}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size.must_equal 1
51
- items.to.must_equal Blather::JID.new(host)
52
- items.node.must_equal node
50
+ items.find("//ns:items[@node=\"#{node}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size.should == 1
51
+ items.to.should == Blather::JID.new(host)
52
+ items.node.should == node
53
53
  end
54
54
 
55
55
  it 'can create an items request node to request some items' do
@@ -60,9 +60,9 @@ describe Blather::Stanza::PubSub::Items do
60
60
  items_xpath = items.map { |i| "@id=\"#{i}\"" } * ' or '
61
61
 
62
62
  items = Blather::Stanza::PubSub::Items.request host, node, items
63
- items.find("//ns:items[@node=\"#{node}\"]/ns:item[#{items_xpath}]", :ns => Blather::Stanza::PubSub.registered_ns).size.must_equal 2
64
- items.to.must_equal Blather::JID.new(host)
65
- items.node.must_equal node
63
+ items.find("//ns:items[@node=\"#{node}\"]/ns:item[#{items_xpath}]", :ns => Blather::Stanza::PubSub.registered_ns).size.should == 2
64
+ items.to.should == Blather::JID.new(host)
65
+ items.node.should == node
66
66
  end
67
67
 
68
68
  it 'can create an items request node to request "max_number" of items' do
@@ -71,9 +71,9 @@ describe Blather::Stanza::PubSub::Items do
71
71
  max = 3
72
72
 
73
73
  items = Blather::Stanza::PubSub::Items.request host, node, nil, max
74
- items.find("//ns:pubsub/ns:items[@node=\"#{node}\" and @max_items=\"#{max}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size.must_equal 1
75
- items.to.must_equal Blather::JID.new(host)
76
- items.node.must_equal node
77
- items.max_items.must_equal max
74
+ items.find("//ns:pubsub/ns:items[@node=\"#{node}\" and @max_items=\"#{max}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size.should == 1
75
+ items.to.should == Blather::JID.new(host)
76
+ items.node.should == node
77
+ items.max_items.should == max
78
78
  end
79
79
  end