File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
lib/opentelemetry/instrumentation/rspec
test/opentelemetry/instrumentation/rspec Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -69,9 +69,15 @@ def example_started(notification)
6969
7070 def example_finished ( notification )
7171 pop_and_finalize_span do |span |
72- result = notification . example . execution_result
73-
74- span . set_attribute ( 'rspec.example.result' , result . status . to_s )
72+ example = notification . example
73+ result = example . execution_result
74+
75+ # Update name and full_description for one-liner examples where description is generated after execution
76+ span . name = example . description
77+ span . add_attributes (
78+ 'rspec.example.full_description' => example . full_description . to_s ,
79+ 'rspec.example.result' => result . status . to_s
80+ )
7581
7682 add_exception_and_failures ( span , result . exception )
7783 end
Original file line number Diff line number Diff line change @@ -356,6 +356,26 @@ def run_example(...)
356356 end
357357 end
358358 end
359+
360+ describe 'one-liner syntax' do
361+ subject do
362+ run_example do
363+ it { is_expected . not_to be_nil }
364+ end
365+ end
366+
367+ it 'has a name that matches the auto-generated description' do
368+ _ ( subject . name ) . must_equal 'is expected not to be nil'
369+ end
370+
371+ it 'has a full_description attribute that includes the group description' do
372+ _ ( subject . attributes [ 'rspec.example.full_description' ] ) . must_equal 'group one is expected not to be nil'
373+ end
374+
375+ it 'records when the example passes' do
376+ _ ( subject . attributes [ 'rspec.example.result' ] ) . must_equal 'passed'
377+ end
378+ end
359379 end
360380
361381 describe 'using a custom tracer provider' do
You can’t perform that action at this time.
0 commit comments