Class: Overseer::Test
- Inherits:
-
Object
- Object
- Overseer::Test
- Defined in:
- lib/overseer/test.rb
Instance Attribute Summary collapse
-
#assertions ⇒ Object
Returns the value of attribute assertions.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#suite ⇒ Object
readonly
Returns the value of attribute suite.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#errors? ⇒ Boolean
Returns
true
or +false depending if the test have outstanding errors or not. -
#failures? ⇒ Boolean
Returns
true
or +false depending if the test have outstanding failures or not. -
#initialize(name, &block) ⇒ Test
constructor
A new instance of Test.
-
#passed? ⇒ Boolean
Returns
true
orfalse
depending if the test is passed or not. -
#run ⇒ Object
Run the test, record the run time and store possible exceptions.
Constructor Details
#initialize(name, &block) ⇒ Test
Returns a new instance of Test.
6 7 8 9 10 11 12 13 |
# File 'lib/overseer/test.rb', line 6 def initialize(name, &block) @name = name @code = block @suite = Overseer.current_suite @errors = [] @failures = [] @assertions = 0 end |
Instance Attribute Details
#assertions ⇒ Object
Returns the value of attribute assertions.
4 5 6 |
# File 'lib/overseer/test.rb', line 4 def assertions @assertions end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/overseer/test.rb', line 3 def code @code end |
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/overseer/test.rb', line 4 def errors @errors end |
#failures ⇒ Object
Returns the value of attribute failures.
4 5 6 |
# File 'lib/overseer/test.rb', line 4 def failures @failures end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/overseer/test.rb', line 3 def name @name end |
#suite ⇒ Object (readonly)
Returns the value of attribute suite.
3 4 5 |
# File 'lib/overseer/test.rb', line 3 def suite @suite end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/overseer/test.rb', line 3 def time @time end |
Instance Method Details
#errors? ⇒ Boolean
Returns true
or +false depending if the test have outstanding errors or not
25 26 27 |
# File 'lib/overseer/test.rb', line 25 def errors? errors.any? end |
#failures? ⇒ Boolean
Returns true
or +false depending if the test have outstanding failures or not
31 32 33 |
# File 'lib/overseer/test.rb', line 31 def failures? failures.any? end |
#passed? ⇒ Boolean
Returns true
or false
depending if the test is passed or not
18 19 20 |
# File 'lib/overseer/test.rb', line 18 def passed? !errors? && !failures? end |
#run ⇒ Object
Run the test, record the run time and store possible exceptions
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/overseer/test.rb', line 38 def run Overseer.current_test = self start_time = Time.now suite.before.call if suite.before begin @code.call rescue Exception => e errors << e ensure begin suite.after.call if suite.after rescue Exception => e errors << e if passed? end @time = Time.now - start_time end end |