Class: QED::Runner
- Inherits:
-
Object
- Object
- QED::Runner
- Defined in:
- lib/qed/runner.rb
Overview
Specificaton Runner
The Runner class loops through a set of specifications and executes each one in turn.
The current working directory is changed to that of the specification script’s. So any relative file references within a spec must take that into account.
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#specs ⇒ Object
readonly
QED::Spec::Runner.configure do def setup(spec) …
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(specs, output = nil) ⇒ Runner
constructor
New Specification.
-
#run_spec(spec) ⇒ Object
Run a specification.
Constructor Details
#initialize(specs, output = nil) ⇒ Runner
New Specification
48 49 50 51 |
# File 'lib/qed/runner.rb', line 48 def initialize(specs, output=nil) @specs = [specs].flatten @output = output || Reporter::DotProgress.new #(self) end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
39 40 41 |
# File 'lib/qed/runner.rb', line 39 def output @output end |
#specs ⇒ Object (readonly)
QED::Spec::Runner.configure do
def setup(spec)
...
end
def teardown(spec)
...
end
end
def self.configure(plugin=nil, &block)
if block_given?
m = Module.new(&block)
m.extend m
@config << m
end
if plugin
@config << plugin
end
end
38 39 40 |
# File 'lib/qed/runner.rb', line 38 def specs @specs end |
Instance Method Details
#check ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/qed/runner.rb', line 54 def check output.report_intro # loop through each specification and run it specs.each do |spec| # create a run context for the spec #@context = Context.new(spec) # run the specification run_spec(spec) end output.report_summary end |
#run_spec(spec) ⇒ Object
Run a specification.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/qed/runner.rb', line 68 def run_spec(spec) #report(spec.description) #script = Script.load(spec, output) script = Script.new(spec, output) # pretty sure this is the thing to do Dir.chdir(File.dirname(spec)) do output.report_start(spec) # TODO <-- plugin in here start (how to set?) #context.instance_eval(&spec.given) if spec.given script.run #spec.steps.each do |step| #output.report_step(self) #step.run(self, spec, context, output) #output.report_step_end(self) #end # TODO <-- plugin in here end #context.instance_eval(&spec.complete) if spec.complete output.report_end(spec) end end |