Sha256: 98d2dd833877c668ab0a4bdbeb04cb44028150f0e72348c92c3e89e6fae5624c

Contents?: true

Size: 1.12 KB

Versions: 369

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 ExampleException, "foo"
        end
      end.to raise_error(ExampleException, "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

369 entries across 369 versions & 1 rubygems

Version Path
appsignal-3.9.2-java spec/support/shared_examples/instrument.rb
appsignal-3.9.2 spec/support/shared_examples/instrument.rb
appsignal-3.9.1-java spec/support/shared_examples/instrument.rb
appsignal-3.9.1 spec/support/shared_examples/instrument.rb
appsignal-3.9.0-java spec/support/shared_examples/instrument.rb
appsignal-3.9.0 spec/support/shared_examples/instrument.rb
appsignal-3.8.1-java spec/support/shared_examples/instrument.rb
appsignal-3.8.1 spec/support/shared_examples/instrument.rb
appsignal-3.8.0-java spec/support/shared_examples/instrument.rb
appsignal-3.8.0 spec/support/shared_examples/instrument.rb
appsignal-3.7.6-java spec/support/shared_examples/instrument.rb
appsignal-3.7.6 spec/support/shared_examples/instrument.rb
appsignal-3.7.2-java spec/support/shared_examples/instrument.rb
appsignal-3.7.2 spec/support/shared_examples/instrument.rb
appsignal-3.7.1-java spec/support/shared_examples/instrument.rb
appsignal-3.7.1 spec/support/shared_examples/instrument.rb
appsignal-3.7.0-java spec/support/shared_examples/instrument.rb
appsignal-3.7.0 spec/support/shared_examples/instrument.rb
appsignal-3.6.5-java spec/support/shared_examples/instrument.rb
appsignal-3.6.5 spec/support/shared_examples/instrument.rb