Sha256: e20541e56478480c1b66253771dcd4fcafc8bfde72af99fcf057b1c2aaf92cf6

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe Miu::Messages::Base do
  describe '#initialize' do
    context 'no args' do
      before { @msg = Miu::Messages::Base.new(:type => 'test') }
      subject { @msg }

      its(:id) { should be_instance_of String }
      its(:time) { should be_instance_of Fixnum }
      its(:network) { should be_instance_of Miu::Resources::Network }
      its(:type) { should eq 'test' }
    end

    context 'with args' do
      before do
        @msg = Miu::Messages::Base.new({
          :id => 123,
          :time => 123,
          :network => {:name => 'test'},
          :type => 'type',
          :content => 'content',
        })
      end
      subject { @msg }

      its(:id) { should eq 123 }
      its(:time) { should eq 123 }
      its(:network) { should be_instance_of Miu::Resources::Network }
      its(:type) { should eq 'type' }
      its(:content) { should eq 'content' }
    end
  end

  describe '#to_h' do
    let(:hash) { Miu::Messages::Base.new(:type => 'test').to_h }

    it { expect(hash).to be_instance_of ::Hash }
    it { expect(hash).to have_key :network }
    it { expect(hash).to have_key :type }
    it { expect(hash).to have_key :content }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miu-0.2.2 spec/miu/messages/base_spec.rb
miu-0.2.1 spec/miu/messages/base_spec.rb