class Magicspec::MagicspecFormatter

Public Class Methods

new(output) click to toggle source
Calls superclass method
# File lib/magicspec/generators/magicspec/config/magicspec_formatter.rb, line 7
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

Public Instance Methods

example_failed(example) click to toggle source

Check if this is browser and we'll add some content.

Calls superclass method
# File lib/magicspec/generators/magicspec/config/magicspec_formatter.rb, line 16
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
example_passed(example) click to toggle source
Calls superclass method
# File lib/magicspec/generators/magicspec/config/magicspec_formatter.rb, line 26
def example_passed(example)
  super(example)
  @printer.flush
end
extra_failure_content(failure) click to toggle source
Calls superclass method
# File lib/magicspec/generators/magicspec/config/magicspec_formatter.rb, line 31
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