Sha256: 003073b6bf236f8dca7887d5f4984e07abb6af1bf9a1b5fdf064f59b6aa307c6

Contents?: true

Size: 1.45 KB

Versions: 26

Compression:

Stored size: 1.45 KB

Contents

require 'rails_helper'

RSpec.describe Bobot::Event::Referral do
  let :payload do
    {
      'sender' => {
        'id' => '3'
      },
      'recipient' => {
        'id' => '3'
      },
      'timestamp' => 1_458_692_752_478,
      'referral' => {
        'ref' => 'my-ref-value',
        'source' => 'SHORTLINK',
        'type' => 'OPEN_THREAD'
      }
    }
  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 '.sent_at' do
    it 'returns when the message was sent' do
      expect(subject.sent_at).to eq(Time.zone.at(payload['timestamp'] / 1000))
    end
  end

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

    it 'returns the source value' do
      expect(subject.referral.source).to eq(payload['referral']['source'])
    end

    it 'returns the type value' do
      expect(subject.referral.type).to eq(payload['referral']['type'])
    end
  end

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

Version data entries

26 entries across 26 versions & 1 rubygems

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