Class Spec::Runner::ContextRunner
In: lib/spec/runner/context_runner.rb
Parent: Object

Methods

Public Class methods

[Source]

    # File lib/spec/runner/context_runner.rb, line 7
 7:       def initialize(options)
 8:         @contexts = []
 9:         @options = options
10:       end

Public Instance methods

[Source]

    # File lib/spec/runner/context_runner.rb, line 12
12:       def add_context(context)
13:         return if !@options.spec_name.nil? unless context.matches?(@options.spec_name)
14:         context.run_single_spec(@options.spec_name) if context.matches?(@options.spec_name)
15:         @contexts << context
16:       end

[Source]

    # File lib/spec/runner/context_runner.rb, line 46
46:       def number_of_specs
47:         @contexts.inject(0) {|sum, context| sum + context.number_of_specs}
48:       end

Runs all contexts and returns the number of failures.

[Source]

    # File lib/spec/runner/context_runner.rb, line 19
19:       def run(exit_when_done)
20:         @options.reporter.start(number_of_specs)
21:         begin
22:           @contexts.each do |context|
23:             context.run(@options.reporter, @options.dry_run)
24:           end
25:         rescue Interrupt
26:         ensure
27:           @options.reporter.end
28:         end
29:         failure_count = @options.reporter.dump
30:         
31:         if(failure_count == 0 && !@options.heckle_runner.nil?)
32:           heckle_runner = @options.heckle_runner
33:           @options.heckle_runner = nil
34:           context_runner = self.class.new(@options)
35:           context_runner.instance_variable_set(:@contexts, @contexts)
36:           heckle_runner.heckle_with(context_runner)
37:         end
38:         
39:         if(exit_when_done)
40:           exit_code = (failure_count == 0) ? 0 : 1
41:           exit(exit_code)
42:         end
43:         failure_count
44:       end

[Validate]