Class: Quarry::Runner
- Defined in:
- lib/quarry/runner.rb,
lib/quarry/runner/context.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.
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#specs ⇒ Object
readonly
Quarry::Spec::Runner.configure do def setup(spec) …
Instance Method Summary collapse
-
#check ⇒ Object
Each spec gets it’s own context.
-
#check_spec(spec) ⇒ Object
Run a specification.
-
#initialize(specs, output = nil) ⇒ Runner
constructor
New Specification.
Constructor Details
#initialize(specs, output = nil) ⇒ Runner
New Specification
47 48 49 50 |
# File 'lib/quarry/runner.rb', line 47 def initialize(specs, output=nil) @specs = [specs].flatten @output = output || Reporter::DotProgress.new #(self) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
39 40 41 |
# File 'lib/quarry/runner.rb', line 39 def context @context end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
37 38 39 |
# File 'lib/quarry/runner.rb', line 37 def output @output end |
#specs ⇒ Object (readonly)
Quarry::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
36 37 38 |
# File 'lib/quarry/runner.rb', line 36 def specs @specs end |
Instance Method Details
#check ⇒ Object
Each spec gets it’s own context.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/quarry/runner.rb', line 53 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 check_spec(spec) end output.report_summary end |
#check_spec(spec) ⇒ Object
Run a specification.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/quarry/runner.rb', line 67 def check_spec(spec) #report(spec.description) # pretty sure this is the thing to do Dir.chdir(File.dirname(spec.file)) do output.report_start(spec) # TODO <-- plugin in here start (how to set?) #context.instance_eval(&spec.given) if spec.given 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 |