Sha256: dd0f9a2599f32e5ccd116b5adf7aea956d867535d5144cdf7cbe58f6dab6dd35

Contents?: true

Size: 1.04 KB

Versions: 26

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 { described_class.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

26 entries across 26 versions & 1 rubygems

Version Path
bobot-5.0.4 spec/bobot/event/read_spec.rb
bobot-5.0.3 spec/bobot/event/read_spec.rb
bobot-5.0.2 spec/bobot/event/read_spec.rb
bobot-5.0.1 spec/bobot/event/read_spec.rb
bobot-5.0.0 spec/bobot/event/read_spec.rb
bobot-4.15.0 spec/bobot/event/read_spec.rb
bobot-4.14.0 spec/bobot/event/read_spec.rb
bobot-4.13.1 spec/bobot/event/read_spec.rb
bobot-4.13.0 spec/bobot/event/read_spec.rb
bobot-4.11.0 spec/bobot/event/read_spec.rb
bobot-4.10.0 spec/bobot/event/read_spec.rb
bobot-4.9.0 spec/bobot/event/read_spec.rb
bobot-4.8.0 spec/bobot/event/read_spec.rb
bobot-4.7.0 spec/bobot/event/read_spec.rb
bobot-4.6.0 spec/bobot/event/read_spec.rb
bobot-4.5.0 spec/bobot/event/read_spec.rb
bobot-4.4.1 spec/bobot/event/read_spec.rb
bobot-4.4.0 spec/bobot/event/read_spec.rb
bobot-4.3.1 spec/bobot/event/read_spec.rb
bobot-4.3.0 spec/bobot/event/read_spec.rb