Class: FlakyTestTracker::Serializers::TestHTMLSerializer

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

Overview

Test HTML serializer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html_serializer: HTMLCommentSerializer.new) ⇒ TestHTMLSerializer

Returns a new instance of TestHTMLSerializer.

Parameters:



20
21
22
# File 'lib/flaky_test_tracker/serializers/test_html_serializer.rb', line 20

def initialize(html_serializer: HTMLCommentSerializer.new)
  @html_serializer = html_serializer
end

Instance Attribute Details

#html_serializerObject (readonly)

Returns the value of attribute html_serializer.



17
18
19
# File 'lib/flaky_test_tracker/serializers/test_html_serializer.rb', line 17

def html_serializer
  @html_serializer
end

Instance Method Details

#deserialize(html) ⇒ FlakyTestTracker::Test

Parameters:

  • html (String)

    The HTML representing a FlakyTestTracker::Test.

Returns:

Raises:

  • FlakyTestTracker::Error::DeserializeError



35
36
37
38
39
40
41
# File 'lib/flaky_test_tracker/serializers/test_html_serializer.rb', line 35

def deserialize(html)
  from_json(
    html_serializer.deserialize(html)
  )
rescue ActiveSupport::JSON.parse_error
  raise FlakyTestTracker::Error::DeserializeError
end

#serialize(test) ⇒ String

Returns The HTML representing the test serialized.

Parameters:

Returns:

  • (String)

    The HTML representing the test serialized.



26
27
28
29
30
# File 'lib/flaky_test_tracker/serializers/test_html_serializer.rb', line 26

def serialize(test)
  html_serializer.serialize(
    to_json(test)
  )
end