Sha256: 23533b6a2887f1e7363297b668c7f1ec475d88b9fb3b4f2533bde9170ef551e8

Contents?: true

Size: 1.38 KB

Versions: 36

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Appsignal::Event do

  describe "#sanitize!" do
    let(:payload) { {:foo => 'bar'} }
    let(:event) { Appsignal::Event.new('event.test', 1, 2, 3, payload) }

    it "should call the sanitizer" do
      expect( Appsignal::ParamsSanitizer ).to receive(:sanitize).with(payload)
      event.sanitize!
    end

    it "should store the result on the payload" do
      Appsignal::ParamsSanitizer.stub(:sanitize => {:foo => 'sanitized'})
      expect {
        event.sanitize!
      }.to change(event, :payload).from(:foo => 'bar').to(:foo => 'sanitized')
    end
  end

  describe "#truncate!" do
    let(:payload) { {:foo => 'bar'} }
    let(:event) { Appsignal::Event.new('event.test', 1, 2, 3, payload) }

    it "should remove the payload" do
      expect {
        event.truncate!
      }.to change(event, :payload).from(:foo => 'bar').to({})
    end
  end

  describe ".event_for_instrumentation" do
    context "with non-moped event" do
      it "should instantiate a new Appsignal::Event" do
        expect( Appsignal::Event ).to receive(:new)
        Appsignal::Event.event_for_instrumentation('query.active_record')
      end
    end

    context "with moped event" do
      it "should instantiate a moped event" do
        expect( Appsignal::Event::MopedEvent ).to receive(:new)
        Appsignal::Event.event_for_instrumentation('query.moped')
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
appsignal-0.11.18 spec/lib/appsignal/event_spec.rb
appsignal-0.11.17 spec/lib/appsignal/event_spec.rb
appsignal-0.11.16 spec/lib/appsignal/event_spec.rb
appsignal-0.11.15 spec/lib/appsignal/event_spec.rb
appsignal-0.11.14 spec/lib/appsignal/event_spec.rb
appsignal-0.11.14.beta.1 spec/lib/appsignal/event_spec.rb
appsignal-0.11.13 spec/lib/appsignal/event_spec.rb
appsignal-0.11.13.beta.4 spec/lib/appsignal/event_spec.rb
appsignal-0.11.13.beta.3 spec/lib/appsignal/event_spec.rb
appsignal-0.11.13.beta.2 spec/lib/appsignal/event_spec.rb
appsignal-0.11.13.beta.1 spec/lib/appsignal/event_spec.rb
appsignal-0.11.13.beta.0 spec/lib/appsignal/event_spec.rb
appsignal-0.11.12 spec/lib/appsignal/event_spec.rb
appsignal-0.11.11 spec/lib/appsignal/event_spec.rb
appsignal-0.11.10 spec/lib/appsignal/event_spec.rb
appsignal-0.11.10.beta.2 spec/lib/appsignal/event_spec.rb
appsignal-0.11.10.beta.1 spec/lib/appsignal/event_spec.rb
appsignal-0.11.9 spec/lib/appsignal/event_spec.rb
appsignal-0.11.8.beta.4 spec/lib/appsignal/event_spec.rb
appsignal-0.11.8.beta.3 spec/lib/appsignal/event_spec.rb