Sha256: 95e0143f2712e8451869ee32731675a98eef29a12c1b89cc75d3c418108282bd

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 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 VerySpecificError, "foo"
        end
      end.to raise_error(VerySpecificError, "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

12 entries across 12 versions & 1 rubygems

Version Path
appsignal-2.3.7 spec/support/shared_examples/instrument.rb
appsignal-2.3.6 spec/support/shared_examples/instrument.rb
appsignal-2.3.6.beta.1 spec/support/shared_examples/instrument.rb
appsignal-2.3.4 spec/support/shared_examples/instrument.rb
appsignal-2.3.3 spec/support/shared_examples/instrument.rb
appsignal-2.3.3.beta.1 spec/support/shared_examples/instrument.rb
appsignal-2.3.2 spec/support/shared_examples/instrument.rb
appsignal-2.3.1 spec/support/shared_examples/instrument.rb
appsignal-2.3.0 spec/support/shared_examples/instrument.rb
appsignal-2.3.0.beta.3 spec/support/shared_examples/instrument.rb
appsignal-2.3.0.beta.2 spec/support/shared_examples/instrument.rb
appsignal-2.3.0.beta.1 spec/support/shared_examples/instrument.rb