Class: Butternut::Formatter

Inherits:
Cucumber::Formatter::Html
  • Object
show all
Defined in:
lib/butternut/formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ Formatter

Returns a new instance of Formatter.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/butternut/formatter.rb', line 12

def initialize(step_mother, io, options)
  # find the format options
  format = options[:formats].detect { |(name, _)| name == "Butternut::Formatter" }
  if !format || !format[1].is_a?(String)
    raise "Butternut::Formatter cannot output to STDOUT"
  end
  out = format[1]

  super
  if File.directory?(out)
    #@assets_dir = out
    #@assets_url = "."
  else
    basename = File.basename(out).sub(/\..*$/, "")
    @assets_dir = File.join(File.dirname(out), basename)
    @assets_url = basename
    if !File.exist?(@assets_dir)
      FileUtils.mkdir(@assets_dir)
    end
  end
end

Instance Method Details

#after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/butternut/formatter.rb', line 39

def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
  return if @hide_this_step
  # print snippet for undefined steps
  if status == :undefined
    step_multiline_class = @step.multiline_arg ? @step.multiline_arg.class : nil
    @builder.pre do |pre|
      pre << @step_mother.snippet_text(@step.actual_keyword,step_match.instance_variable_get("@name") || '',step_multiline_class)
    end
  end
  add_page_source_link(@builder)
  @builder << '</li>'
end

#before_feature_element(feature_element) ⇒ Object



34
35
36
37
# File 'lib/butternut/formatter.rb', line 34

def before_feature_element(feature_element)
  super
  @feature_element = feature_element
end