Class: Easytest::Case
- Inherits:
-
Object
- Object
- Easytest::Case
- Defined in:
- lib/easytest/case.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#only ⇒ Object
(also: #only?)
readonly
Returns the value of attribute only.
-
#skipped ⇒ Object
(also: #skipped?)
readonly
Returns the value of attribute skipped.
Instance Method Summary collapse
-
#initialize(name:, skipped: false, only: false, block: nil) ⇒ Case
constructor
A new instance of Case.
- #run ⇒ Object
- #skip! ⇒ Object
Constructor Details
#initialize(name:, skipped: false, only: false, block: nil) ⇒ Case
Returns a new instance of Case.
12 13 14 15 16 17 18 |
# File 'lib/easytest/case.rb', line 12 def initialize(name:, skipped: false, only: false, block: nil) @name = name @file = (caller_locations(3, 1)&.first&.absolute_path or raise) @block = block @skipped = skipped @only = only end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/easytest/case.rb', line 5 def block @block end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/easytest/case.rb', line 4 def file @file end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/easytest/case.rb', line 3 def name @name end |
#only ⇒ Object (readonly) Also known as: only?
Returns the value of attribute only.
7 8 9 |
# File 'lib/easytest/case.rb', line 7 def only @only end |
#skipped ⇒ Object (readonly) Also known as: skipped?
Returns the value of attribute skipped.
6 7 8 |
# File 'lib/easytest/case.rb', line 6 def skipped @skipped end |
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/easytest/case.rb', line 24 def run return [:todo, Reporter.new(name).report_todo] unless block return [:skipped, Reporter.new(name).report_skip] if skipped? block.call [:passed, nil] rescue MatchError, FatalError => error report = Reporter.new(name).report_error(error) or raise error [:failed, report] end |
#skip! ⇒ Object
20 21 22 |
# File 'lib/easytest/case.rb', line 20 def skip! @skipped = true end |