Skip to content

Instantly share code, notes, and snippets.

@terotil
Created September 10, 2009 08:59
Show Gist options
  • Save terotil/184428 to your computer and use it in GitHub Desktop.
Save terotil/184428 to your computer and use it in GitHub Desktop.
class ScreenshotFormatter < Cucumber::Formatter::Pretty # Cucumber::Ast::Visitor
def self.browser=(browser)
@@browser = browser
end
def self.screenshot_path=(path)
@@sspath = path
end
def visit_step(step)
@step_id = step.dom_id
super
end
def screenshot_after_step?(keyword, step_match, status)
raise 'Mein Gott! Abstract method!'
end
def visit_step_name(keyword, step_match, status, source_indent, background)
if screenshot_after_step?(keyword, step_match, status)
@@browser.capture_entire_page_screenshot("#{@@sspath}/#{@step_id}.png",'')
# Ruutukaappaus koko ruudusta
# @@browser.capture_screenshot("tmp/#{@step_id}_screen.png")
end
super
end
end
class ScreenshotAllFormatter < ScreenshotFormatter
def screenshot_after_step?(keyword, step_match, status)
true
end
end
class ScreenshotFailingFormatter < ScreenshotFormatter
def screenshot_after_step?(keyword, step_match, status)
status == :failed
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment