Class: TallyAction

Inherits:
Object show all
Defined in:
lib/mspec/runner/actions/tally.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTallyAction


83
84
85
# File 'lib/mspec/runner/actions/tally.rb', line 83

def initialize
  @counter = Tally.new
end

Instance Attribute Details

#counterObject (readonly)

Returns the value of attribute counter


81
82
83
# File 'lib/mspec/runner/actions/tally.rb', line 81

def counter
  @counter
end

Instance Method Details

#example(state, block) ⇒ Object

Callback for the MSpec :example event. Increments the tally of examples.


121
122
123
# File 'lib/mspec/runner/actions/tally.rb', line 121

def example(state, block)
  @counter.examples!
end

#exception(exception) ⇒ Object

Callback for the MSpec :exception event. Increments the tally of errors and failures.


115
116
117
# File 'lib/mspec/runner/actions/tally.rb', line 115

def exception(exception)
  exception.failure? ? @counter.failures! : @counter.errors!
end

#expectation(state) ⇒ Object

Callback for the MSpec :expectation event. Increments the tally of expectations (e.g. #should, #should_receive, etc.).


109
110
111
# File 'lib/mspec/runner/actions/tally.rb', line 109

def expectation(state)
  @counter.expectations!
end

#formatObject


130
131
132
# File 'lib/mspec/runner/actions/tally.rb', line 130

def format
  @counter.format
end

#loadObject


103
104
105
# File 'lib/mspec/runner/actions/tally.rb', line 103

def load
  @counter.files!
end

#registerObject


87
88
89
90
91
92
93
# File 'lib/mspec/runner/actions/tally.rb', line 87

def register
  MSpec.register :load,        self
  MSpec.register :exception,   self
  MSpec.register :example,     self
  MSpec.register :tagged,      self
  MSpec.register :expectation, self
end

#tagged(state) ⇒ Object


125
126
127
128
# File 'lib/mspec/runner/actions/tally.rb', line 125

def tagged(state)
  @counter.examples!
  @counter.tagged!
end

#unregisterObject


95
96
97
98
99
100
101
# File 'lib/mspec/runner/actions/tally.rb', line 95

def unregister
  MSpec.unregister :load,        self
  MSpec.unregister :exception,   self
  MSpec.unregister :example,     self
  MSpec.unregister :tagged,      self
  MSpec.unregister :expectation, self
end