Class: RSpec::Core::Formatters::SnapshotFormatter
- Defined in:
- lib/watirmark/formatters/snapshot_formatter.rb
Instance Method Summary collapse
- #example_failed(example) ⇒ Object
-
#initialize(output) ⇒ SnapshotFormatter
constructor
A new instance of SnapshotFormatter.
Constructor Details
#initialize(output) ⇒ SnapshotFormatter
Returns a new instance of SnapshotFormatter.
7 8 9 10 11 |
# File 'lib/watirmark/formatters/snapshot_formatter.rb', line 7 def initialize(output) super @path=output.path + "_dir/" Dir.mkdir(@path) if not File::directory?( @path ) end |
Instance Method Details
#example_failed(example) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/watirmark/formatters/snapshot_formatter.rb', line 13 def example_failed(example) if Page.browser_exists? append_text = example.description.gsub(/([^\w-])/, "_") snapshot = "#{Time.now.to_i} - #{append_text}.png" Page.browser.screenshot.save "#{@path}/#{snapshot}" end rescue Exception => e # an exception occurred. We don't want exception to occur here or we'll get false positive test results. Watirmark.logger.warn "An exception was rescued in example_failed for SnapshotFormatter. This exception is ignored" end |