Class: ScreenshotMaker
- Inherits:
-
Object
- Object
- ScreenshotMaker
- Defined in:
- lib/acceptance_test/screenshot_maker.rb
Instance Attribute Summary collapse
-
#basedir ⇒ Object
Returns the value of attribute basedir.
Instance Method Summary collapse
-
#initialize(basedir) ⇒ ScreenshotMaker
constructor
A new instance of ScreenshotMaker.
- #make(page, options) ⇒ Object
- #screenshot_url(options) ⇒ Object
Constructor Details
#initialize(basedir) ⇒ ScreenshotMaker
Returns a new instance of ScreenshotMaker.
4 5 6 |
# File 'lib/acceptance_test/screenshot_maker.rb', line 4 def initialize basedir @basedir = basedir end |
Instance Attribute Details
#basedir ⇒ Object
Returns the value of attribute basedir.
2 3 4 |
# File 'lib/acceptance_test/screenshot_maker.rb', line 2 def basedir @basedir end |
Instance Method Details
#make(page, options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/acceptance_test/screenshot_maker.rb', line 8 def make page, FileUtils.mkdir_p basedir unless File.exist? basedir file_path = [:file_path] name = screenshot_name(build_name(file_path), [:line_number]) path = File.("#{basedir}/#{name}") page.save_screenshot(path) end |
#screenshot_url(options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/acceptance_test/screenshot_maker.rb', line 19 def screenshot_url file_path = [:file_path] if [:screenshot_url_base] name = screenshot_name(build_name(file_path), [:line_number]) "#{[:screenshot_url_base]}/#{name}" else name = screenshot_name(build_name(file_path), [:line_number]) path = File.("#{basedir}/#{name}") "file:///#{path}" end end |