Class: HTMLRender::RenderTest::DirectoryRenderTest
- Inherits:
-
Object
- Object
- HTMLRender::RenderTest::DirectoryRenderTest
- Defined in:
- lib/html_render/render_test.rb
Overview
Tests, across browsers, that some HTML renders correctly.
A DirectoryRenderTest works within a particular directory in the filesystem, and it expects the following files:
-
html.html
-
canonical.png (what we want it to look like)
-
valid/SERVER.png for each SYSTEM (i.e., “ff3”, “winxp-ie6”, etc.)
-
runs/20080331014523/SERVER.png (at the time “run” was called)
Calling run() with a hash of servers (see HtmlRender::RenderBatches::HTTPRenderBatch) will batch-render for each server, potentially throwing a HtmlRender::Renderers::HTTPRenderer::ServerError if the render fails. It will return an HtmlRender::RenderTest::Result.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#run_path ⇒ Object
readonly
Returns the value of attribute run_path.
-
#test_path ⇒ Object
readonly
Returns the value of attribute test_path.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(test_path, run_path) {|_self| ... } ⇒ DirectoryRenderTest
constructor
A new instance of DirectoryRenderTest.
-
#last_result ⇒ Object
Returns the results of the last test.
- #run(servers_hash) ⇒ Object
Constructor Details
#initialize(test_path, run_path) {|_self| ... } ⇒ DirectoryRenderTest
Returns a new instance of DirectoryRenderTest.
133 134 135 136 137 138 |
# File 'lib/html_render/render_test.rb', line 133 def initialize(test_path, run_path, &block) @test_path = test_path @run_path = run_path yield(self) if block_given? end |
Instance Attribute Details
#run_path ⇒ Object (readonly)
Returns the value of attribute run_path.
131 132 133 |
# File 'lib/html_render/render_test.rb', line 131 def run_path @run_path end |
#test_path ⇒ Object (readonly)
Returns the value of attribute test_path.
131 132 133 |
# File 'lib/html_render/render_test.rb', line 131 def test_path @test_path end |
Instance Method Details
#html ⇒ Object
140 141 142 143 144 |
# File 'lib/html_render/render_test.rb', line 140 def html @html ||= File.open(html_path) do |f| f.read end end |
#last_result ⇒ Object
Returns the results of the last test. If the “valid” results changed since the last time run() was called, then last_result.pass? may return a different value than before (since it will compare the previously-generated actual .png’s with the newer expected .png’s).
164 165 166 |
# File 'lib/html_render/render_test.rb', line 164 def last_result DirectoryResult.new(run_path, valid_path, canonical_path) end |
#run(servers_hash) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/html_render/render_test.rb', line 146 def run(servers_hash) clear_run_directory begin batch = HTMLRender::RenderBatches::HTTPRenderBatch.new(servers_hash) batch.render_html_to_directory(html, run_path) rescue Exception => e clear_run_directory raise e end last_result end |