Sha256: 23e6106c87fca3e33a3e0ce4fd5a7107ef9e0331fdd0f446611472721b7ff84a

Contents?: true

Size: 1.29 KB

Versions: 44

Compression:

Stored size: 1.29 KB

Contents

RSpec.shared_examples "instrument helper" do
  around { |example| keep_transactions { example.run } }
  let(:stub) { double(:method_call => "return value") }

  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"

    expect_transaction_to_have_event
  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")

      expect_transaction_to_have_event
    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)

      expect_transaction_to_have_event
    end
  end

  def expect_transaction_to_have_event
    expect(transaction).to include_event(
      "name" => "name",
      "title" => "title",
      "body" => "body",
      "body_format" => Appsignal::EventFormatter::DEFAULT
    )
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
appsignal-4.0.6-java spec/support/shared_examples/instrument.rb
appsignal-4.0.6 spec/support/shared_examples/instrument.rb
appsignal-4.0.5-java spec/support/shared_examples/instrument.rb
appsignal-4.0.5 spec/support/shared_examples/instrument.rb
appsignal-4.0.4-java spec/support/shared_examples/instrument.rb
appsignal-4.0.4 spec/support/shared_examples/instrument.rb
appsignal-4.0.3-java spec/support/shared_examples/instrument.rb
appsignal-4.0.3 spec/support/shared_examples/instrument.rb
appsignal-4.0.2-java spec/support/shared_examples/instrument.rb
appsignal-4.0.2 spec/support/shared_examples/instrument.rb
appsignal-4.0.1-java spec/support/shared_examples/instrument.rb
appsignal-4.0.1 spec/support/shared_examples/instrument.rb
appsignal-4.0.0-java spec/support/shared_examples/instrument.rb
appsignal-4.0.0 spec/support/shared_examples/instrument.rb
appsignal-3.13.1-java spec/support/shared_examples/instrument.rb
appsignal-3.13.1 spec/support/shared_examples/instrument.rb
appsignal-3.13.1.alpha.1-java spec/support/shared_examples/instrument.rb
appsignal-3.13.1.alpha.1 spec/support/shared_examples/instrument.rb
appsignal-4.0.0.beta.2-java spec/support/shared_examples/instrument.rb
appsignal-4.0.0.beta.2 spec/support/shared_examples/instrument.rb