lib/cucumber/formatter/html.rb in casecumber-1.0.2.1 vs lib/cucumber/formatter/html.rb in casecumber-1.2.1.cb2

- old
+ new

@@ -141,11 +141,11 @@ @builder << '</div>' end def background_name(keyword, name, file_colon_line, source_indent) @listing_background = true - @builder.h3 do |h3| + @builder.h3(:id => "background_#{@scenario_number}") do |h3| @builder.span(keyword, :class => 'keyword') @builder.text!(' ') @builder.span(name, :class => 'val') end end @@ -219,11 +219,11 @@ def after_step(step) move_progress end - def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) + def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) @step_match = step_match @hide_this_step = false if exception if @exceptions.include?(exception) @hide_this_step = true @@ -239,11 +239,11 @@ return if @hide_this_step set_scenario_color(status) @builder << "<li id='#{@step_id}' class='step #{status}'>" end - def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) + def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) 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| @@ -252,11 +252,11 @@ end @builder << '</li>' print_messages end - def step_name(keyword, step_match, status, source_indent, background) + def step_name(keyword, step_match, status, source_indent, background, file_colon_line) @step_matches ||= [] background_in_scenario = background && !@listing_background @skip_step = @step_matches.index(step_match) || background_in_scenario @step_matches << step_match @@ -289,11 +289,11 @@ end def doc_string(string) return if @hide_this_step @builder.pre(:class => 'val') do |pre| - @builder << h(string.gsub("\n", '&#x000A;')) + @builder << h(string).gsub("\n", '&#x000A;') end end def before_table_row(table_row) @@ -309,11 +309,11 @@ @builder << '</tr>' if table_row.exception @builder.tr do @builder.td(:colspan => @col_index.to_s, :class => 'failed') do @builder.pre do |pre| - pre << format_exception(table_row.exception) + pre << h(format_exception(table_row.exception)) end end end set_scenario_color_failed end @@ -373,12 +373,18 @@ @builder.div(:class => 'message') do message = exception.message if defined?(RAILS_ROOT) && message.include?('Exception caught') matches = message.match(/Showing <i>(.+)<\/i>(?:.+) #(\d+)/) backtrace += ["#{RAILS_ROOT}/#{matches[1]}:#{matches[2]}"] if matches - message = message.match(/<code>([^(\/)]+)<\//m)[1] + matches = message.match(/<code>([^(\/)]+)<\//m) + message = matches ? matches[1] : "" end + + unless exception.instance_of?(RuntimeError) + message = "#{message} (#{exception.class})" + end + @builder.pre do @builder.text!(message) end end @builder.div(:class => 'backtrace') do @@ -505,10 +511,10 @@ end def inline_js_content <<-EOF - SCENARIOS = "h3[id^='scenario_']"; + SCENARIOS = "h3[id^='scenario_'],h3[id^=background_]"; $(document).ready(function() { $(SCENARIOS).css('cursor', 'pointer'); $(SCENARIOS).click(function() { $(this).siblings().toggle(250);