Sha256: f360752c60369c36d1cc4c1b2d5553baec0a37e91bc2819152fb76a1fb75060c

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

module ReplayApi
  describe Client do
    subject(:client) { Client.new(configuration) }
    let(:connection) { double :connection, post: nil }
    let(:configuration) { Configuration.new.tap { |c| c.replay_key = 'my_key' } }
    before do
      client.connection = connection
    end

    describe '#event' do
      let(:event) { Event.new }
      let(:payload) { { replay_key: 'my_key' }.merge event.compact_attributes }

      it 'yields the provided event' do
        expect { |b| client.event(event, &b) }.to yield_with_args(event)
      end

      it 'posts the event' do
        client.event(event)
        expect(connection).to have_received(:post).with('/events', payload)
      end
    end

    describe '#trait' do
      let(:trait) { Trait.new }
      let(:payload) { { replay_key: 'my_key' }.merge trait.compact_attributes }

      it 'yields the provided trait' do
        expect { |b| client.trait(trait, &b) }.to yield_with_args(trait)
      end

      it 'posts the trait' do
        client.trait(trait)
        expect(connection).to have_received(:post).with('/traits', payload)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
replay_api-0.0.3 spec/replay_api/client_spec.rb