class ProbeDockRSpec::Formatter
Public Class Methods
new(output)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 12 def initialize output config = ProbeDockRSpec.config @client = Client.new config.server, config.client_options @test_run = TestRun.new config.project @groups = [] end
Public Instance Methods
close(notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 50 def close notification @client.process @test_run end
example_failed(example_notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 41 def example_failed example_notification add_result example_notification, false end
example_group_finished(group_notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 29 def example_group_finished group_notification @groups.pop end
example_group_started(group_notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 25 def example_group_started group_notification @groups << group_notification.group end
example_passed(example_notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 37 def example_passed example_notification add_result example_notification, true end
example_started(example_notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 33 def example_started example_notification @current_time = Time.now end
start(notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 21 def start notification @start_time = Time.now end
stop(notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 45 def stop notification end_time = Time.now @test_run.duration = ((end_time - @start_time) * 1000).round end
Private Instance Methods
add_result(example_notification, successful)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 56 def add_result example_notification, successful options = { passed: successful, duration: ((Time.now - @current_time) * 1000).round } options[:message] = failure_message example_notification unless successful @test_run.add_result example_notification.example, @groups, options end
failure_message(example_notification)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 68 def failure_message example_notification String.new.tap do |m| m << example_notification.description m << "\n" m << example_notification.message_lines.collect{ |l| " #{l}" }.join("\n") m << "\n" m << example_notification.formatted_backtrace.collect{ |l| " # #{l}" }.join("\n") end end
full_example_name(example)
click to toggle source
# File lib/probe_dock_rspec/formatter.rb, line 78 def full_example_name example (@groups.collect{ |g| g.description.strip } << example.description.strip).join ' ' end