Sha256: 382a718127eeaffc7fe282b66730cde295b59ff5ccea48923eb059ddc1535efe

Contents?: true

Size: 1016 Bytes

Versions: 4

Compression:

Stored size: 1016 Bytes

Contents

require 'spec_helper'

describe Appsignal::Elasticsearch do
  let(:client)  { Elasticsearch::Client.new }
  let(:event)   { @events.pop }
  let(:payload) { event.payload }

  before(:all) do
    @events = []
    ActiveSupport::Notifications.subscribe('query.elasticsearch') do |*args|
      @events << ActiveSupport::Notifications::Event.new(*args)
    end
  end

  context 'client.exists?' do
    let(:index) { 'foobar4321' }
    let(:type)  { 'sometype' }
    let(:id)    { '1234' }

    before { client.exists? index: index, type: type, id: id }

    context 'payload' do
      it 'has the correct method' do
        expect(payload[:query][:method]).to eq 'HEAD'
      end

      it 'has the correct path' do
        expect(payload[:query][:path]).to eq "#{index}/#{type}/#{id}"
      end

      it 'has the correct exception' do
        expect(payload[:exception][0]).to eq 'Elasticsearch::Transport::Transport::Errors::NotFound'
        expect(payload[:exception][1]).to eq '[404] '
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-elasticsearch-0.0.4 spec/appsignal_elasticsearch_spec.rb
appsignal-elasticsearch-0.0.3 spec/appsignal_elasticsearch_spec.rb
appsignal-elasticsearch-0.0.2 spec/appsignal_elasticsearch_spec.rb
appsignal-elasticsearch-0.0.1 spec/appsignal_elasticsearch_spec.rb