Class: Test::Recorder
- Inherits:
-
Object
- Object
- Test::Recorder
- Defined in:
- lib/rubytest/recorder.rb
Overview
Recorder class is an observer that tracks all tests that are run and categorizes them according to their test status.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #error(test, exception) ⇒ Object
- #fail(test, exception) ⇒ Object
-
#initialize ⇒ Recorder
constructor
A new instance of Recorder.
-
#method_missing(*a) ⇒ Object
Ignore any other signals.
-
#pass(test) ⇒ Object
Add ‘test` to pass set.
- #skip_test(test, reason) ⇒ Object
-
#success? ⇒ Boolean
Returns true if their are no test errors or failures.
- #todo(test, exception) ⇒ Object
Constructor Details
#initialize ⇒ Recorder
Returns a new instance of Recorder.
8 9 10 |
# File 'lib/rubytest/recorder.rb', line 8 def initialize @table = Hash.new{ |h,k| h[k] = [] } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*a) ⇒ Object
Ignore any other signals.
48 49 |
# File 'lib/rubytest/recorder.rb', line 48 def method_missing(*a) end |
Instance Method Details
#[](key) ⇒ Object
12 13 14 |
# File 'lib/rubytest/recorder.rb', line 12 def [](key) @table[key.to_sym] end |
#error(test, exception) ⇒ Object
30 31 32 |
# File 'lib/rubytest/recorder.rb', line 30 def error(test, exception) self[:error] << [test, exception] end |
#fail(test, exception) ⇒ Object
26 27 28 |
# File 'lib/rubytest/recorder.rb', line 26 def fail(test, exception) self[:fail] << [test, exception] end |
#pass(test) ⇒ Object
Add ‘test` to pass set.
22 23 24 |
# File 'lib/rubytest/recorder.rb', line 22 def pass(test) self[:pass] << test end |
#skip_test(test, reason) ⇒ Object
17 18 19 |
# File 'lib/rubytest/recorder.rb', line 17 def skip_test(test, reason) self[:skip] << [test, reason] end |
#success? ⇒ Boolean
Returns true if their are no test errors or failures.
43 44 45 |
# File 'lib/rubytest/recorder.rb', line 43 def success? self[:error].size + self[:fail].size > 0 ? false : true end |
#todo(test, exception) ⇒ Object
34 35 36 |
# File 'lib/rubytest/recorder.rb', line 34 def todo(test, exception) self[:todo] << [test, exception] end |