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
-
#initialize(settings = {}, &procedure) ⇒ TestProc
constructor
New test procedure.
- #match?(match) ⇒ Boolean
- #scope ⇒ Object
-
#skip? ⇒ Boolean
Don’t run test?.
-
#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 |
# File 'lib/lemon/test_proc.rb', line 9 def initialize(settings={}, &procedure) @context = settings[:context] @setup = settings[:setup] @label = settings[:label] @skip = settings[:skip] @procedure = procedure @tested = false end |
Instance Attribute Details
#context ⇒ Object (readonly)
The parent case to which this test belongs.
23 24 25 |
# File 'lib/lemon/test_proc.rb', line 23 def context @context end |
#label ⇒ Object (readonly)
Description of test.
29 30 31 |
# File 'lib/lemon/test_proc.rb', line 29 def label @label end |
#procedure ⇒ Object (readonly)
Test procedure, in which test assertions should be made.
32 33 34 |
# File 'lib/lemon/test_proc.rb', line 32 def procedure @procedure end |
#setup ⇒ Object (readonly)
Setup and teardown procedures.
26 27 28 |
# File 'lib/lemon/test_proc.rb', line 26 def setup @setup end |
#skip ⇒ Object
Returns the value of attribute skip.
43 44 45 |
# File 'lib/lemon/test_proc.rb', line 43 def skip @skip end |
#tested ⇒ Object
Has this test been executed?
51 52 53 |
# File 'lib/lemon/test_proc.rb', line 51 def tested @tested end |
Instance Method Details
#arguments ⇒ Object
TODO: handle parameterized tests
87 88 89 |
# File 'lib/lemon/test_proc.rb', line 87 def arguments [] end |
#call ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/lemon/test_proc.rb', line 104 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
99 100 101 |
# File 'lib/lemon/test_proc.rb', line 99 def match?(match) match == target || match === description end |
#scope ⇒ Object
113 114 115 |
# File 'lib/lemon/test_proc.rb', line 113 def scope context.scope end |
#skip? ⇒ Boolean
Don’t run test?
46 47 48 |
# File 'lib/lemon/test_proc.rb', line 46 def skip? @skip end |
#target ⇒ Object
Target method of context.
38 39 40 |
# File 'lib/lemon/test_proc.rb', line 38 def target context.target end |
#to_proc ⇒ Object
92 93 94 95 96 |
# File 'lib/lemon/test_proc.rb', line 92 def to_proc lambda do call end end |
#to_s ⇒ Object Also known as: name
Test label.
54 55 56 |
# File 'lib/lemon/test_proc.rb', line 54 def to_s label.to_s end |
#topic ⇒ Object
Ruby Test looks for #topic as the description of test setup.
61 62 63 |
# File 'lib/lemon/test_proc.rb', line 61 def topic setup.to_s end |