opal/opal/rspec/formatter/html_printer.rb in opal-rspec-0.5.0.beta3 vs opal/opal/rspec/formatter/html_printer.rb in opal-rspec-0.5.0
- old
+ new
@@ -22,12 +22,16 @@
# From here, we'll do more direct DOM manipulation
reset_output
@root_node = Element.klass 'results'
end
+ def current_node
+ @group_stack.last ? @group_stack.last : @root_node
+ end
+
def flush_output
- node = @group_stack.last ? @group_stack.last : @root_node
+ node = current_node
new_node = Element.from_string(@output.string)
node.append new_node
reset_output
end
@@ -36,11 +40,11 @@
end
def print_example_group_start(group_id, description, number_of_parents)
super
@output.puts '</dl></div>'
- parent_node = @group_stack.last ? @group_stack.last : @root_node
+ parent_node = current_node
new_node = Element.from_string(@output.string)
reset_output
parent_node << new_node
@group_stack << new_node.get_child_by_tag_name('dl')
# We won't have this in the DOM until group ends, so need to queue up yellow/red updates
@@ -58,9 +62,17 @@
end
def print_example_failed(pending_fixed, description, run_time, failure_id, exception, extra_content, escape_backtrace=false)
super
flush_output
+ example_we_just_wrote = current_node.get_child_by_tag_name('dd', index=-1)
+ dump_message = lambda do
+ puts "Exception for example '#{description}'\n#{exception[:backtrace]}"
+ false
+ end
+ button = Element.from_string('<form><button type="button">Console</button></form>')
+ button.on_click = dump_message
+ example_we_just_wrote << button
end
def print_example_pending(description, pending_message)
super
flush_output