Sha256: f0a5c2f694fef84c2bd693e0f3db485c0b34ed633f8d49d4a90da52fe400f057

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

require 'rails_helper'

RSpec.describe Bobot::Event::Read do
  let :payload do
    {
      'sender' => {
        'id' => '3'
      },
      'recipient' => {
        'id' => '3'
      },
      'timestamp' => 145_776_419_762_7,
      'read' => {
        'watermark' => 145_866_885_625_3,
        'seq' => 38
      }
    }
  end

  subject { Bobot::Event::Read.new(payload) }

  describe '.messaging' do
    it 'returns the original payload' do
      expect(subject.messaging).to eq(payload)
    end
  end

  describe '.sender' do
    it 'returns the sender' do
      expect(subject.sender).to eq(payload['sender'])
    end
  end

  describe '.recipient' do
    it 'returns the recipient' do
      expect(subject.recipient).to eq(payload['recipient'])
    end
  end

  describe '.at' do
    it 'returns when the message was read' do
      expect(subject.at).to eq(Time.zone.at(payload['read']['watermark'] / 1000))
    end
  end

  describe '.seq' do
    it 'returns the read sequence number' do
      expect(subject.seq).to eq(payload['read']['seq'])
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
bobot-3.7.3 spec/bobot/event/read_spec.rb
bobot-3.7.2 spec/bobot/event/read_spec.rb
bobot-3.6.3 spec/bobot/event/read_spec.rb
bobot-3.6.0 spec/bobot/event/read_spec.rb
bobot-3.5.2 spec/bobot/event/read_spec.rb
bobot-3.5.1 spec/bobot/event/read_spec.rb
bobot-3.5.0 spec/bobot/event/read_spec.rb
bobot-3.0.7 spec/bobot/event/read_spec.rb
bobot-3.0.6 spec/bobot/event/read_spec.rb
bobot-3.0.5 spec/bobot/event/read_spec.rb
bobot-3.0.3 spec/bobot/event/read_spec.rb
bobot-3.0.2 spec/bobot/event/read_spec.rb
bobot-3.0.1 spec/bobot/event/read_spec.rb
bobot-2.6.2 spec/bobot/event/read_spec.rb
bobot-2.6.1 spec/bobot/event/read_spec.rb
bobot-2.6.0 spec/bobot/event/read_spec.rb
bobot-2.5.0 spec/bobot/event/read_spec.rb
bobot-2.3.0 spec/bobot/event/read_spec.rb
bobot-2.1.0 spec/bobot/event/read_spec.rb
bobot-1.0.53 spec/bobot/event/read_spec.rb