Class: Busted::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/busted/counter.rb

Instance Method Summary collapse

Constructor Details

#initialize(stack = Stack.new) ⇒ Counter

Returns a new instance of Counter.



6
7
8
# File 'lib/busted/counter.rb', line 6

def initialize(stack = Stack.new)
  @stack = stack
end

Instance Method Details

#finishObject



14
15
16
# File 'lib/busted/counter.rb', line 14

def finish
  stack.finished = counts
end

#reportObject



18
19
20
21
22
23
24
25
# File 'lib/busted/counter.rb', line 18

def report
  started = stack.started
  finished = stack.finished

  [:method, :constant].each_with_object({}) do |counter, result|
    result[counter] = finished[counter] - started[counter]
  end
end

#startObject



10
11
12
# File 'lib/busted/counter.rb', line 10

def start
  stack.started = counts
end