spec/blather/stanza_spec.rb in blather-0.2.1 vs spec/blather/stanza_spec.rb in blather-0.2.2
- old
+ new
@@ -1,10 +1,10 @@
require File.join(File.dirname(__FILE__), *%w[.. spec_helper])
describe 'Blather::Stanza' do
it 'provides .next_id helper for generating new IDs' do
- proc { Stanza.next_id }.must_change 'Stanza', :next_id
+ proc { Stanza.next_id }.must_change 'Stanza.next_id'
end
it 'can import a node' do
s = Stanza.import XMPPNode.new('foo')
s.element_name.must_equal 'foo'
@@ -89,7 +89,19 @@
s['type'].must_be_nil
s.type = 'testing'
s.type.wont_be_nil
s['type'].wont_be_nil
+ end
+
+ it 'can be converted into an error by error name' do
+ s = Stanza.new('message')
+ err = s.as_error 'internal-server-error', 'cancel'
+ err.must_be_instance_of StanzaError::InternalServerError
+ end
+
+ it 'can be converted into an error by error class' do
+ s = Stanza.new('message')
+ err = s.as_error StanzaError::InternalServerError, 'cancel'
+ err.must_be_instance_of StanzaError::InternalServerError
end
end