Class: StoredReporter

Inherits:
Riot::SilentReporter
  • Object
show all
Defined in:
lib/dashboard/stored_reporter.rb

Defined Under Namespace

Classes: ContextResult, Fail, Pass

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string_io) ⇒ StoredReporter

Returns a new instance of StoredReporter.



54
55
56
57
58
59
60
61
# File 'lib/dashboard/stored_reporter.rb', line 54

def initialize string_io
  @string_io = string_io
  
  # lookup hash for contexts to handle nesting
  @contexts = {}
  @context_results = []
  super()
end

Instance Attribute Details

#context_resultsObject

Returns the value of attribute context_results.



52
53
54
# File 'lib/dashboard/stored_reporter.rb', line 52

def context_results
  @context_results
end

Instance Method Details

#context_finishedObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dashboard/stored_reporter.rb', line 63

def context_finished
  return unless @current_result
  
  @current_result.requests = RequestTrap.trap.clone
  RequestTrap.trap.clear
  # 
  # str = @string_io.string
  # # puts "flushing with #{str} inside #{@current_result.desc}"
  # # @current_result.curls = str.split(/\n/).select{|x| x.index("curl") == 0} if @current_result
  # @string_io.truncate 0
end

#describe_context(context) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/dashboard/stored_reporter.rb', line 75

def describe_context context
  context_finished
  @current_result = ContextResult.new context    
  @contexts[context] = @current_result
  
  if context.parent && @contexts[context.parent]
    @contexts[context.parent].children << @current_result
  else
    # it's a top level result
    @context_results << @current_result
  end
  
  super context
end

#error(*args) ⇒ Object



94
95
96
# File 'lib/dashboard/stored_reporter.rb', line 94

def error *args
  @current_result.fail Fail.new *args
end

#fail(*args) ⇒ Object



98
99
100
# File 'lib/dashboard/stored_reporter.rb', line 98

def fail *args
  @current_result.fail Fail.new *args
end

#pass(*args) ⇒ Object



90
91
92
# File 'lib/dashboard/stored_reporter.rb', line 90

def pass *args
  @current_result.pass Pass.new *args
end