Class: Buildkite::TestCollector::RSpecPlugin::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/buildkite/test_collector/rspec_plugin/trace.rb

Constant Summary collapse

FILE_PATH_REGEX =
/^(.*?\.(rb|feature))/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(example, history:, failure_reason: nil, failure_expanded: []) ⇒ Trace

Returns a new instance of Trace.



10
11
12
13
14
15
# File 'lib/buildkite/test_collector/rspec_plugin/trace.rb', line 10

def initialize(example, history:, failure_reason: nil, failure_expanded: [])
  @example = example
  @history = history
  @failure_reason = failure_reason
  @failure_expanded = failure_expanded
end

Instance Attribute Details

#exampleObject

Returns the value of attribute example.



5
6
7
# File 'lib/buildkite/test_collector/rspec_plugin/trace.rb', line 5

def example
  @example
end

#failure_expandedObject

Returns the value of attribute failure_expanded.



5
6
7
# File 'lib/buildkite/test_collector/rspec_plugin/trace.rb', line 5

def failure_expanded
  @failure_expanded
end

#failure_reasonObject

Returns the value of attribute failure_reason.



5
6
7
# File 'lib/buildkite/test_collector/rspec_plugin/trace.rb', line 5

def failure_reason
  @failure_reason
end

#historyObject (readonly)

Returns the value of attribute history.



6
7
8
# File 'lib/buildkite/test_collector/rspec_plugin/trace.rb', line 6

def history
  @history
end

Instance Method Details

#as_hashObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/buildkite/test_collector/rspec_plugin/trace.rb', line 25

def as_hash
  strip_invalid_utf8_chars(
    scope: example.example_group.[:full_description],
    name: example.description,
    location: example.location,
    file_name: file_name,
    result: result,
    failure_reason: failure_reason,
    failure_expanded: failure_expanded,
    history: history,
  ).select { |_, value| !value.nil? }
end

#resultObject



17
18
19
20
21
22
23
# File 'lib/buildkite/test_collector/rspec_plugin/trace.rb', line 17

def result
  case example.execution_result.status
  when :passed; "passed"
  when :failed; "failed"
  when :pending; "skipped"
  end
end