lib/watirsplash/html_formatter.rb in watirsplash-1.0.0 vs lib/watirsplash/html_formatter.rb in watirsplash-1.1.0
- old
+ new
@@ -1,7 +1,6 @@
require 'rspec/core/formatters/html_formatter'
-require 'win32/screenshot'
require 'pathname'
require 'fileutils'
module WatirSplash
# Custom RSpec formatter for WatirSplash
@@ -37,11 +36,11 @@
example.metadata[:description] += "#{example.metadata[:location].scan(/:\d+$/)} (#{Time.now.strftime("%H:%M:%S")})"
super
end
def extra_failure_content(exception) # :nodoc:
- if @browser.exists?
+ if @browser && @browser.exists?
save_screenshot
save_html
end
content = []
@@ -70,16 +69,10 @@
file_name
end
def save_screenshot(description="Screenshot", hwnd=nil) # :nodoc:
file_name = file_path("screenshot.png", description)
- hwnd ||= @browser.hwnd
- @browser.bring_to_front
- begin
- Win32::Screenshot::Take.of(:window, :hwnd => hwnd).write(file_name)
- rescue => e
- $stderr.puts "saving of screenshot failed: #{e.message}"
- end
+ @browser.save_screenshot(:file_name => file_name, :hwnd => hwnd)
file_name
end
# Generates unique file name and path for each example.
#