Class: RSpec::Buildkite::Analytics::Uploader::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/buildkite/analytics/uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(example, history) ⇒ Trace

Returns a new instance of Trace.



28
29
30
31
32
33
34
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 28

def initialize(example, history)
  @id = SecureRandom.uuid
  @example = example
  @history = history
  @failure_reason = nil
  @failure_expanded = []
end

Instance Attribute Details

#exampleObject

Returns the value of attribute example.



25
26
27
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 25

def example
  @example
end

#failure_expandedObject

Returns the value of attribute failure_expanded.



25
26
27
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 25

def failure_expanded
  @failure_expanded
end

#failure_reasonObject

Returns the value of attribute failure_reason.



25
26
27
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 25

def failure_reason
  @failure_reason
end

#historyObject (readonly)

Returns the value of attribute history.



26
27
28
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 26

def history
  @history
end

#idObject (readonly)

Returns the value of attribute id.



26
27
28
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 26

def id
  @id
end

Instance Method Details

#as_hashObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 44

def as_hash
  strip_invalid_utf8_chars(
    id: @id,
    scope: example.example_group.[:full_description],
    name: example.description,
    identifier: example.id,
    location: example.location,
    file_name: generate_file_name(example),
    result: result_state,
    failure_reason: failure_reason,
    failure_expanded: failure_expanded,
    history: history,
  ).with_indifferent_access.compact
end

#result_stateObject



36
37
38
39
40
41
42
# File 'lib/rspec/buildkite/analytics/uploader.rb', line 36

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