Class: RSpec::Rewind::ExampleContext

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/rewind/example_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(example:) ⇒ ExampleContext

Returns a new instance of ExampleContext.



6
7
8
# File 'lib/rspec/rewind/example_context.rb', line 6

def initialize(example:)
  @example = example
end

Instance Method Details

#idObject



22
23
24
# File 'lib/rspec/rewind/example_context.rb', line 22

def id
  source.respond_to?(:id) ? source.id : 'unknown'
end

#metadataObject



16
17
18
19
20
# File 'lib/rspec/rewind/example_context.rb', line 16

def 
  return {} unless source.respond_to?(:metadata)

  source. || {}
end

#sourceObject



10
11
12
13
14
# File 'lib/rspec/rewind/example_context.rb', line 10

def source
  return @example.example if @example.respond_to?(:example) && @example.example

  @example
end