Sha256: c41f59340d557ffed8544e09831263e311de37b4f8fbde263952df7f5f10ece1

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 KB

Contents

require File.join(File.dirname(__FILE__), *%w[.. .. spec_helper])

describe 'Blather::Stanza::Message' do
  it 'registers itself' do
    XMPPNode.class_from_registration(:message, nil).must_equal Stanza::Message
  end

  it 'provides "attr_accessor" for body' do
    s = Stanza::Message.new
    s.body.must_be_nil
    s.detect { |n| n.element_name == 'body' }.must_be_nil

    s.body = 'test message'
    s.body.wont_be_nil
    s.detect { |n| n.element_name == 'body' }.wont_be_nil
  end

  it 'provides "attr_accessor" for subject' do
    s = Stanza::Message.new
    s.subject.must_be_nil
    s.detect { |n| n.element_name == 'subject' }.must_be_nil

    s.subject = 'test subject'
    s.subject.wont_be_nil
    s.detect { |n| n.element_name == 'subject' }.wont_be_nil
  end

  it 'provides "attr_accessor" for thread' do
    s = Stanza::Message.new
    s.thread.must_be_nil
    s.detect { |n| n.element_name == 'thread' }.must_be_nil

    s.thread = 1234
    s.thread.wont_be_nil
    s.detect { |n| n.element_name == 'thread' }.wont_be_nil
  end

  it 'ensures type is one of Stanza::Message::VALID_TYPES' do
    lambda { Stanza::Message.new nil, nil, :invalid_type_name }.must_raise(Blather::ArgumentError)

    Stanza::Message::VALID_TYPES.each do |valid_type|
      msg = Stanza::Message.new nil, nil, valid_type
      msg.type.must_equal valid_type
    end
  end

  Stanza::Message::VALID_TYPES.each do |valid_type|
    it "provides a helper (#{valid_type}?) for type #{valid_type}" do
      Stanza::Message.new.must_respond_to :"#{valid_type}?"
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
sprsquish-blather-0.2.3 spec/blather/stanza/message_spec.rb
sprsquish-blather-0.3.0 spec/blather/stanza/message_spec.rb
sprsquish-blather-0.3.1 spec/blather/stanza/message_spec.rb
sprsquish-blather-0.3.2 spec/blather/stanza/message_spec.rb
sprsquish-blather-0.3.3 spec/blather/stanza/message_spec.rb
sprsquish-blather-0.3.4 spec/blather/stanza/message_spec.rb
blather-0.2.1 spec/blather/stanza/message_spec.rb
blather-0.2.2 spec/blather/stanza/message_spec.rb
blather-0.2 spec/blather/stanza/message_spec.rb
blather-0.2.3 spec/blather/stanza/message_spec.rb
blather-0.3.0 spec/blather/stanza/message_spec.rb
blather-0.3.1 spec/blather/stanza/message_spec.rb
blather-0.3.4 spec/blather/stanza/message_spec.rb
blather-0.3.3 spec/blather/stanza/message_spec.rb
blather-0.3.2 spec/blather/stanza/message_spec.rb