Class: CucumberCinema::Camera
- Inherits:
-
Object
- Object
- CucumberCinema::Camera
- Defined in:
- lib/cucumber_cinema/camera.rb
Instance Method Summary collapse
- #store_image(png_filename, html_filename, destination_dir) ⇒ Object
- #take_screenshot(body, options = {}) ⇒ Object
Instance Method Details
#store_image(png_filename, html_filename, destination_dir) ⇒ Object
4 5 6 |
# File 'lib/cucumber_cinema/camera.rb', line 4 def store_image(png_filename, html_filename, destination_dir) `wkhtmltoimage #{Capybara.save_and_open_page_path}/#{$cucumber_cinema_dir_name}/#{html_filename} #{destination_dir}/#{png_filename}` end |
#take_screenshot(body, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cucumber_cinema/camera.rb', line 8 def take_screenshot(body, ={}) prepare($cucumber_cinema_dir_name) name = [:name] || rand(10**10) html_filename="#{$cucumber_cinema_prefix}-#{name}.html" png_filename = "#{$cucumber_cinema_prefix}-#{name}.png" Capybara.save_page(body.to_str, "#{$cucumber_cinema_dir_name}/#{html_filename}") destination_dir ="#{$cucumber_cinema_location}/#{$cucumber_cinema_dir_name}" store_image(png_filename, html_filename, destination_dir) thumb = thumbnail(destination_dir, png_filename) store_hash(png_filename, name, thumb) end |