Class: CapybaraHtmlFormatter

Inherits:
RSpec::Core::Formatters::HtmlFormatter
  • Object
show all
Includes:
ERB::Util, HTMLReport
Defined in:
lib/sim/html_formatter.rb

Instance Method Summary collapse

Methods included from HTMLReport

#example_failed_helper, #example_passed_helper, #move_tmp_to_final, #print_screenshot_helper

Constructor Details

#initialize(output) ⇒ CapybaraHtmlFormatter



10
11
12
13
14
# File 'lib/sim/html_formatter.rb', line 10

def initialize(output)
  super
  # raise "output has to be a file path!" unless output.is_a?(String)
  @output_dir = File.dirname(@output)
end

Instance Method Details

#example_failed(example) ⇒ Object



23
24
25
26
27
28
# File 'lib/sim/html_formatter.rb', line 23

def example_failed(example)
  example_failed_helper(example, @output)
  
  @printer.flush
  @output.flush
end

#example_group_finished(example_group) ⇒ Object



34
35
36
# File 'lib/sim/html_formatter.rb', line 34

def example_group_finished(example_group)
  super(example_group)
end

#example_group_started(example_group) ⇒ Object



30
31
32
# File 'lib/sim/html_formatter.rb', line 30

def example_group_started(example_group)
  super(example_group)
end

#example_passed(example) ⇒ Object



16
17
18
19
20
21
# File 'lib/sim/html_formatter.rb', line 16

def example_passed(example)
  example_passed_helper(example, @output)

  @printer.flush
  @output.flush
end

#example_pending(example) ⇒ Object



48
49
50
# File 'lib/sim/html_formatter.rb', line 48

def example_pending(example)
  super(example)
end

#example_started(example) ⇒ Object



38
39
40
# File 'lib/sim/html_formatter.rb', line 38

def example_started(example)
  super(example)
end

#extra_failure_content(failure) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/sim/html_formatter.rb', line 52

def extra_failure_content(failure)
  content = []
  content << "<span>"
  content << ""
  content << "</span>"
  super + content.join($/)
end


60
61
62
63
64
65
66
# File 'lib/sim/html_formatter.rb', line 60

def link_for(file_name)
  return unless file_name && File.exists?(file_name)

  description = File.extname(file_name).upcase[1..-1]
  path = Pathname.new(file_name)
  "<a href='#{path.relative_path_from(Pathname.new(@output_dir))}'>#{description}</a>&nbsp;"
end


42
43
44
45
46
# File 'lib/sim/html_formatter.rb', line 42

def print_screenshot(example)
  print_screenshot_helper(example, @output)
 
  @output.flush
end