Skip to content

Commit

Permalink
more probe tests
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Sep 17, 2024
1 parent 5823450 commit 83a7761
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions spec/datadog/di/probe_spec.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
require "datadog/di/probe"

RSpec.describe Datadog::DI::Probe do
shared_context 'method probe' do
let(:probe) do
described_class.new(id: "42", type: "foo", type_name: "Foo", method_name: "bar")
end
end

shared_context 'line probe' do
let(:probe) do
described_class.new(id: "42", type: "foo", file: "foo.rb", line_no: 4)
end
end

describe ".new" do
context "method probe" do
let(:probe) do
described_class.new(id: "42", type: "foo", type_name: "foo", method_name: "bar")
end
include_context 'method probe'

it "creates an instance" do
expect(probe).to be_a(described_class)
expect(probe.id).to eq "42"
expect(probe.type).to eq "foo"
expect(probe.type_name).to eq "foo"
expect(probe.type_name).to eq "Foo"
expect(probe.method_name).to eq "bar"
expect(probe.file).to be nil
expect(probe.line_no).to be nil
end
end

context "line probe" do
let(:probe) do
described_class.new(id: "42", type: "foo", file: "foo", line_no: 4)
end
include_context 'line probe'

it "creates an instance" do
expect(probe).to be_a(described_class)
expect(probe.id).to eq "42"
expect(probe.type).to eq "foo"
expect(probe.type_name).to be nil
expect(probe.method_name).to be nil
expect(probe.file).to eq "foo"
expect(probe.file).to eq "foo.rb"
expect(probe.line_no).to eq 4
end
end
Expand Down Expand Up @@ -161,4 +169,22 @@
end
end
end

describe '#location' do
context 'method probe' do
include_context 'method probe'

it 'returns method location' do
expect(probe.location).to eq 'Foo.bar'
end
end

context 'line probe' do
include_context 'line probe'

it 'returns line location' do
expect(probe.location).to eq 'foo.rb:4'
end
end
end
end

0 comments on commit 83a7761

Please sign in to comment.