Class: Lemon::TestProc
- Inherits:
-
Object
- Object
- Lemon::TestProc
- Defined in:
- lib/lemon/test_proc.rb
Overview
Test procedure.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
The parent case to which this test belongs.
-
#label ⇒ Object
readonly
Description of test.
-
#procedure ⇒ Object
readonly
Test procedure, in which test assertions should be made.
-
#setup ⇒ Object
readonly
Setup and teardown procedures.
-
#skip ⇒ Object
Returns the value of attribute skip.
-
#tested ⇒ Object
Has this test been executed?.
Instance Method Summary collapse
-
#arguments ⇒ Object
TODO: handle parameterized tests.
-
#call ⇒ Object
Run the test.
-
#initialize(settings = {}, &procedure) ⇒ TestProc
constructor
New test procedure.
- #match?(match) ⇒ Boolean
- #scope ⇒ Object
-
#skip? ⇒ Boolean
Don’t run test?.
- #tags ⇒ Object
-
#target ⇒ Object
Target method of context.
- #to_proc ⇒ Object
-
#to_s ⇒ Object
(also: #name)
Test label.
-
#topic ⇒ Object
Ruby Test looks for #topic as the description of test setup.
Constructor Details
#initialize(settings = {}, &procedure) ⇒ TestProc
New test procedure.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/lemon/test_proc.rb', line 9 def initialize(settings={}, &procedure) @context = settings[:context] @setup = settings[:setup] @label = settings[:label] @skip = settings[:skip] @tags = settings[:tags] @procedure = procedure @tested = false end |
Instance Attribute Details
#context ⇒ Object (readonly)
The parent case to which this test belongs.
24 25 26 |
# File 'lib/lemon/test_proc.rb', line 24 def context @context end |
#label ⇒ Object (readonly)
Description of test.
30 31 32 |
# File 'lib/lemon/test_proc.rb', line 30 def label @label end |
#procedure ⇒ Object (readonly)
Test procedure, in which test assertions should be made.
33 34 35 |
# File 'lib/lemon/test_proc.rb', line 33 def procedure @procedure end |
#setup ⇒ Object (readonly)
Setup and teardown procedures.
27 28 29 |
# File 'lib/lemon/test_proc.rb', line 27 def setup @setup end |
#skip ⇒ Object
Returns the value of attribute skip.
46 47 48 |
# File 'lib/lemon/test_proc.rb', line 46 def skip @skip end |
#tested ⇒ Object
Has this test been executed?
63 64 65 |
# File 'lib/lemon/test_proc.rb', line 63 def tested @tested end |
Instance Method Details
#arguments ⇒ Object
TODO: handle parameterized tests
105 106 107 |
# File 'lib/lemon/test_proc.rb', line 105 def arguments [] end |
#call ⇒ Object
Run the test.
128 129 130 131 132 133 134 |
# File 'lib/lemon/test_proc.rb', line 128 def call context.run(self) do setup.run_setup(scope) if setup scope.instance_exec(*arguments, &procedure) setup.run_teardown(scope) if setup end end |
#match?(match) ⇒ Boolean
121 122 123 |
# File 'lib/lemon/test_proc.rb', line 121 def match?(match) match == target || match === description end |
#scope ⇒ Object
139 140 141 |
# File 'lib/lemon/test_proc.rb', line 139 def scope context.scope end |
#skip? ⇒ Boolean
Don’t run test?
51 52 53 |
# File 'lib/lemon/test_proc.rb', line 51 def skip? @skip end |
#tags ⇒ Object
58 59 60 |
# File 'lib/lemon/test_proc.rb', line 58 def @tags end |
#target ⇒ Object
Target method of context.
41 42 43 |
# File 'lib/lemon/test_proc.rb', line 41 def target context.target end |
#to_proc ⇒ Object
112 113 114 115 116 |
# File 'lib/lemon/test_proc.rb', line 112 def to_proc lambda do call end end |
#to_s ⇒ Object Also known as: name
Test label.
68 69 70 |
# File 'lib/lemon/test_proc.rb', line 68 def to_s label.to_s end |
#topic ⇒ Object
This may be deprecated in future RubyTest.
Ruby Test looks for #topic as the description of test setup.
79 80 81 |
# File 'lib/lemon/test_proc.rb', line 79 def topic setup.to_s end |