EOS
end
def print_main_footer(total_count, failed_count, pending_count, total_time)
update_report_js_tmp = ''
update_report_js = ''
%w{ total_count failed_count pending_count total_time }.each do |key|
update_report_js += update_report_js_tmp % [key, eval(key)]
end
"#{update_report_js}
"
end
def print_tab_speed_statsitics(passed_scenarios)
statistics = TurnipFormatter::Template::Tab::SpeedStatistics.new(passed_scenarios)
<<-EOS
Ranking of running time of each successfully scenario:
#{statistics.build}
EOS
end
def print_tab_feature_statsitics(scenarios)
statistics = TurnipFormatter::Template::Tab::FeatureStatistics.new(scenarios)
<<-EOS
The results for the feature:
#{statistics.build}
EOS
end
def print_tab_tag_statsitics(scenarios)
statistics = TurnipFormatter::Template::Tab::TagStatistics.new(scenarios)
<<-EOS
The results for the tab:
#{statistics.build}
EOS
end
def print_footer
<<-EOS
EOS
end
def print_scenario(scenario)
template_scenario.result(binding)
end
def print_runtime_error(example, exception)
if example.exception
example_backtrace = format_backtrace(example.exception.backtrace[0..14], example.metadata).map do |l|
RSpec::Core::Metadata::relative_path(l)
end
end
template_exception.result(binding)
end
private
def feature_name(scenario)
path = RSpec::Core::Metadata::relative_path(scenario.feature_file_path)
name = scenario.feature_name
"\"#{name}\" in #{path}"
end
def scenario_tags(scenario)
return '' if scenario.tags.empty?
template_scenario_tags.result(binding)
end
def step_attr(step)
attr = 'step'
attr += " #{step.status}" if step.attention?
"class=\"#{h(attr)}\""
end
def step_args(step)
output = []
step.docs.each do |style, template|
if style == :extra_args
output << step_extra_args(template[:value])
else
output << step_template(style, template[:klass]).build(template[:value])
end
end
output.join("\n")
end
def step_extra_args(extra_args)
extra_args.map do |arg|
klass = arg.instance_of?(Turnip::Table) ? StepOutline : StepMultiline
klass.build(arg)
end.join("\n")
end
def step_template(style, klass)
return klass if !!klass
# call Built-in template (StepException, StepSource, etc...)
klass = ['step', style.to_s].map(&:capitalize).join
self.class.const_get(klass)
end
def report_area
<<-EOS
Turnip Report
Scenario ( failed pending).
Finished in
EOS
end
def template_scenario
@template_scenario ||= ERB.new(<<-EOS)
¶
Scenario: <%= h(scenario.name) %>
(Feature: <%= h(feature_name(scenario)) %>)
at <%= h(scenario.run_time) %> sec
<%= scenario_tags(scenario) %>
<% scenario.steps.each do |step| %>
><%= h(step.name) %>
<%= step_args(step) %>
<% end %>
EOS
end
def template_scenario_tags
@template_scenario_tags ||= ERB.new(<<-EOS)
<% scenario.tags.each do |tag| %>
@<%= h(tag) %>
<% end %>
EOS
end
def template_exception
@template_exception ||= ERB.new(<<-EOS)