Class Spec::Runner::BehaviourRunner
In: lib/spec/runner/behaviour_runner.rb
Parent: Object

Methods

Constants

FILE_SORTERS = { 'mtime' => lambda {|file_a, file_b| File.mtime(file_b) <=> File.mtime(file_a)}

Public Class methods

[Source]

   # File lib/spec/runner/behaviour_runner.rb, line 5
5:       def initialize(options)
6:         @behaviours = []
7:         @options = options
8:       end

Public Instance methods

[Source]

    # File lib/spec/runner/behaviour_runner.rb, line 10
10:       def add_behaviour(behaviour)
11:         if !specified_examples.nil? && !specified_examples.empty? #&& behaviour.matches?(specified_examples)
12:           behaviour.retain_examples_matching!(specified_examples) #if behaviour.matches?(specified_examples)
13:         end
14:         @behaviours << behaviour if behaviour.number_of_examples != 0 && !behaviour.shared?
15:       end

[Source]

    # File lib/spec/runner/behaviour_runner.rb, line 49
49:       def number_of_examples
50:         @behaviours.inject(0) {|sum, behaviour| sum + behaviour.number_of_examples}
51:       end

Runs all contexts and returns the number of failures.

[Source]

    # File lib/spec/runner/behaviour_runner.rb, line 18
18:       def run(paths, exit_when_done)
19:         unless paths.nil? # It's nil when running single specs with ruby
20:           paths = find_paths(paths)
21:           sorted_paths = sort_paths(paths)
22:           load_specs(sorted_paths) 
23:         end
24:         @options.reporter.start(number_of_examples)
25:         behaviours = @options.reverse ? @behaviours.reverse : @behaviours
26:         begin
27:           run_behaviours(behaviours)
28:         rescue Interrupt
29:         ensure
30:           @options.reporter.end
31:         end
32:         failure_count = @options.reporter.dump
33:         
34:         heckle if(failure_count == 0 && !@options.heckle_runner.nil?)
35:         
36:         if(exit_when_done)
37:           exit_code = (failure_count == 0) ? 0 : 1
38:           exit(exit_code)
39:         end
40:         failure_count
41:       end

[Source]

    # File lib/spec/runner/behaviour_runner.rb, line 43
43:       def run_behaviours(behaviours)
44:         behaviours.each do |behaviour|
45:           behaviour.run(@options.reporter, @options.dry_run, @options.reverse, @options.timeout)
46:         end
47:       end

[Source]

    # File lib/spec/runner/behaviour_runner.rb, line 61
61:       def sort_paths(paths)
62:         sorter = sorter(paths)
63:         paths = paths.sort(&sorter) unless sorter.nil?
64:         paths
65:       end

[Source]

    # File lib/spec/runner/behaviour_runner.rb, line 57
57:       def sorter(paths)
58:         FILE_SORTERS[@options.loadby]
59:       end

[Validate]