Class: Quarry::Markup::Step
Overview
Step
Direct Known Subclasses
Instance Attribute Summary collapse
-
#after ⇒ Object
readonly
Returns the value of attribute after.
-
#before ⇒ Object
readonly
Returns the value of attribute before.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
-
#spec ⇒ Object
(also: #parent)
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
-
#initialize(spec, code, lineno, ioc = {}) ⇒ Step
constructor
A new instance of Step.
-
#run(runner, spec, context, output) ⇒ Object
Run specification step.
- #tab ⇒ Object
- #to_s ⇒ Object
-
#to_script ⇒ Object
As could appear in stand-alone script.
Constructor Details
#initialize(spec, code, lineno, ioc = {}) ⇒ Step
Returns a new instance of Step.
16 17 18 19 20 21 22 23 |
# File 'lib/quarry/markup/step.rb', line 16 def initialize(spec, code, lineno, ioc={}) @spec = spec @code = code.rstrip @lineno = lineno @before = ioc[:before] @after = ioc[:after] end |
Instance Attribute Details
#after ⇒ Object (readonly)
Returns the value of attribute after.
14 15 16 |
# File 'lib/quarry/markup/step.rb', line 14 def after @after end |
#before ⇒ Object (readonly)
Returns the value of attribute before.
13 14 15 |
# File 'lib/quarry/markup/step.rb', line 13 def before @before end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
10 11 12 |
# File 'lib/quarry/markup/step.rb', line 10 def code @code end |
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
11 12 13 |
# File 'lib/quarry/markup/step.rb', line 11 def lineno @lineno end |
#spec ⇒ Object (readonly) Also known as: parent
Returns the value of attribute spec.
9 10 11 |
# File 'lib/quarry/markup/step.rb', line 9 def spec @spec end |
Instance Method Details
#run(runner, spec, context, output) ⇒ Object
Run specification step.
TODO: Would spec.before + spec.code be better?
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/quarry/markup/step.rb', line 35 def run(runner, spec, context, output) output.report_step(self) #context.instance_eval(runner.before, spec.file) if runner.before context.instance_eval(before.code, spec.file) if before begin context.instance_eval(code, spec.file, lineno) output.report_pass(self) rescue Assertion => error output.report_fail(self, error) rescue Exception => error output.report_error(self, error) ensure context.instance_eval(after.code, spec.file) if after #context.instance_eval(runner.after, spec.file) if runner.after end end |
#tab ⇒ Object
53 54 55 |
# File 'lib/quarry/markup/step.rb', line 53 def tab @tab ||= to_s.index(/\S/) end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/quarry/markup/step.rb', line 58 def to_s code end |
#to_script ⇒ Object
As could appear in stand-alone script.
63 64 65 66 67 68 69 |
# File 'lib/quarry/markup/step.rb', line 63 def to_script script = [] script << before.code if before script << code script << before.code if after script .join("\n") end |