Class: CucumberCinema::Camera

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_cinema/camera.rb

Instance Method Summary collapse

Instance Method Details

#take_screenshot(body, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/cucumber_cinema/camera.rb', line 4

def take_screenshot(body, options={})
  create_directory($cucumber_cinema_dir_name)
  name = options[:name] || rand(10**10)
  filename="#{$cucumber_cinema_dir_name}/#{$cucumber_cinema_prefix}-#{name}"
  Capybara.save_page(body.to_str, "#{filename}.html")
  screenshot_name="#{$cucumber_cinema_location}/#{filename}.png"
  $cucumber_cinema_all_screenshots<<
      {"thumbnail_url"=>screenshot_name, "url"=>screenshot_name, "name"=>name}
  `wkhtmltoimage #{Capybara.save_and_open_page_path}/#{filename}.html #{screenshot_name}`
end