Sha256: 7357b852774b3cb6e7eec9a08d9858095eacc705239d8abf840ffb855616c012

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

RSpec.shared_examples "instrument helper" do
  let(:stub) { double }
  before do
    expect(stub).to receive(:method_call).and_return("return value")

    expect(transaction).to receive(:start_event)
    expect(transaction).to receive(:finish_event).with(
      "name",
      "title",
      "body",
      0
    )
  end

  it "records an event around the given block" do
    return_value = instrumenter.instrument "name", "title", "body" do
      stub.method_call
    end
    expect(return_value).to eq "return value"
  end

  context "with an error raised in the passed block" do
    it "records an event around the given block" do
      expect do
        instrumenter.instrument "name", "title", "body" do
          stub.method_call
          raise "foo"
        end
      end.to raise_error(StandardError, "foo")
    end
  end

  context "with an error raise in the passed block" do
    it "records an event around the given block" do
      expect do
        instrumenter.instrument "name", "title", "body" do
          stub.method_call
          throw :foo
        end
      end.to throw_symbol(:foo)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appsignal-2.2.1 spec/support/shared_examples/instrument.rb