Sha256: 8cdaf4390f55621909d5b717a0785308c4a6907b359c9744174bcb7fba1114ef
Contents?: true
Size: 1.63 KB
Versions: 10
Compression:
Stored size: 1.63 KB
Contents
require 'erb' require 'rspec/core/formatters/html_formatter' require './config/override' module Magicspec class MagicspecFormatter < ::RSpec::Core::Formatters::HtmlFormatter def initialize(output) output = File.new(File.expand_path(File.join('.', 'app', 'reports', "#{Time.now.strftime("%Y%m%d_%H%M%S")}.html")), 'w') super(output) @printer.class.send(:define_method, 'puts') do |what| @output.puts what end #define_method end # Check if this is browser and we'll add some content. def example_failed(example) super(example) if $navi failed_url = $navi.url rescue $navi.current_url @printer.puts "<a target=\"_blank\" href=\"#{failed_url}\">failed url is [#{failed_url}]</a>" @printer.puts '<br />' @printer.flush end #if end def example_passed(example) super(example) @printer.flush end def extra_failure_content(failure) browser = example_group.before_all_ivars[:@browser] || @browser # If we'ere dealing with a browser get a screenshot on failure if browser browser.screenshot.save File.expand_path(File.join('.', 'app', 'reports','screenshots', "#{Time.now.strftime("%Y%m%d_%H%M%S")}.png")) # Need to figure out how to remotely upload content = [] content << "<span>" content << "<a target='_blank' href='http://127.0.0.1:8020/o365/app/reports/screenshots/20131031_103612.png'>screenshot</a>" content << "</span>" super + content.join($/) end end end #MagicspecFormatter end #Magicspec
Version data entries
10 entries across 10 versions & 1 rubygems