Class: HTMLRender::RenderTest::Result::ServerResult

Inherits:
Object
  • Object
show all
Defined in:
lib/html_render/render_test.rb

Overview

The portion of a result specific to an individual server

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, expected_path, actual_path) ⇒ ServerResult

Initializes the ServerResult.

Params:

server: name of the server
expected_path: Path to image we expected
actual_path: Path to image we got


18
19
20
21
22
# File 'lib/html_render/render_test.rb', line 18

def initialize(server, expected_path, actual_path)
  @server = server
  @expected_path = expected_path
  @actual_path = actual_path
end

Instance Attribute Details

#actual_pathObject (readonly)

Returns the value of attribute actual_path.



10
11
12
# File 'lib/html_render/render_test.rb', line 10

def actual_path
  @actual_path
end

#expected_pathObject (readonly)

Returns the value of attribute expected_path.



10
11
12
# File 'lib/html_render/render_test.rb', line 10

def expected_path
  @expected_path
end

#serverObject (readonly)

Returns the value of attribute server.



10
11
12
# File 'lib/html_render/render_test.rb', line 10

def server
  @server
end

Instance Method Details

#actualObject



32
33
34
35
36
37
38
# File 'lib/html_render/render_test.rb', line 32

def actual
  @actual ||= if actual_path
    File.open(actual_path) do |f|
      HTMLRender::Images::PNGImage.new(f.read)
    end
  end
end

#differenceObject



44
45
46
# File 'lib/html_render/render_test.rb', line 44

def difference
  expected.difference(actual)
end

#expectedObject



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

def expected
  @expected ||= if expected_path
    File.open(expected_path) do |f|
      HTMLRender::Images::PNGImage.new(f.read)
    end
  end
end

#pass?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/html_render/render_test.rb', line 40

def pass?
  actual == expected
end