Class: Lemon::TestSetup
- Inherits:
-
Object
- Object
- Lemon::TestSetup
- Defined in:
- lib/lemon/test_setup.rb
Overview
Test Subject - Setup and Teardown code.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
The test case to which this advice belong.
-
#description ⇒ Object
readonly
The description of this concern.
-
#setup ⇒ Object
readonly
Setup procedure.
-
#teardown ⇒ Object
Teardown procedure.
Instance Method Summary collapse
-
#initialize(context, description, options = {}, &setup) ⇒ TestSetup
constructor
New case instance.
-
#run_setup(scope) ⇒ Object
Setup.
-
#run_teardown(scope) ⇒ Object
Teardown.
-
#to_s ⇒ Object
Returns the description with newlines removed.
Constructor Details
#initialize(context, description, options = {}, &setup) ⇒ TestSetup
New case instance.
20 21 22 23 24 25 26 27 |
# File 'lib/lemon/test_setup.rb', line 20 def initialize(context, description, ={}, &setup) @context = context @description = description.to_s #@singleton = options[:singleton] #@type = options[:type] || :context @setup = [setup].flatten @teardown = [] end |
Instance Attribute Details
#context ⇒ Object (readonly)
The test case to which this advice belong.
7 8 9 |
# File 'lib/lemon/test_setup.rb', line 7 def context @context end |
#description ⇒ Object (readonly)
The description of this concern. Make this as detailed as you wish.
11 12 13 |
# File 'lib/lemon/test_setup.rb', line 11 def description @description end |
#setup ⇒ Object (readonly)
Setup procedure.
14 15 16 |
# File 'lib/lemon/test_setup.rb', line 14 def setup @setup end |
#teardown ⇒ Object
Teardown procedure.
17 18 19 |
# File 'lib/lemon/test_setup.rb', line 17 def teardown @teardown end |
Instance Method Details
#run_setup(scope) ⇒ Object
Setup.
35 36 37 38 39 |
# File 'lib/lemon/test_setup.rb', line 35 def run_setup(scope) setup.each do |proc| scope.instance_eval(&proc) end end |
#run_teardown(scope) ⇒ Object
Teardown.
42 43 44 45 46 |
# File 'lib/lemon/test_setup.rb', line 42 def run_teardown(scope) teardown.each do |proc| scope.instance_eval(&proc) end end |
#to_s ⇒ Object
Returns the description with newlines removed.
49 50 51 |
# File 'lib/lemon/test_setup.rb', line 49 def to_s description.gsub(/\n/, ' ') end |