Class: FlakyTestTracker::TestInputFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/flaky_test_tracker/test_input_factory.rb

Overview

Create TestInput instance from Test and attributes.

Instance Method Summary collapse

Instance Method Details

#build(test:, source:, attributes:) ⇒ Object

Parameters:

  • test. (Test)
  • source (#file_source_location_uri #source_uri)
  • attributes. (Hash)

Returns:

  • TestInput



14
15
16
17
18
19
20
21
22
# File 'lib/flaky_test_tracker/test_input_factory.rb', line 14

def build(test:, source:, attributes:)
  FlakyTestTracker::TestInput.new(
    attributes.merge(
      resolved_at: nil,
      number_occurrences: build_test_input_number_occurrences(test: test),
      source_location_url: build_test_input_source_location_url(source: source, attributes: attributes)
    )
  )
end

#build_test_input_number_occurrences(test:) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/flaky_test_tracker/test_input_factory.rb', line 24

def build_test_input_number_occurrences(test:)
  if test
    test.number_occurrences + 1
  else
    1
  end
end

#build_test_input_source_location_url(source:, attributes:) ⇒ Object



32
33
34
35
36
37
# File 'lib/flaky_test_tracker/test_input_factory.rb', line 32

def build_test_input_source_location_url(source:, attributes:)
  source.file_source_location_uri(
    file_path: attributes[:file_path],
    line_number: attributes[:line_number]
  ).to_s
end