Skip to content
This repository
tree: 3b1e67ee93
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 52 lines (43 sloc) 1.28 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
module RSpec
  module Core
    class CommandLine
      def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
        @options = options
        @configuration = configuration
        @world = world
      end

      def run(err, out)
        @options.configure(@configuration)
        @configuration.error_stream = err
        @configuration.output_stream = out
        @configuration.require_files_to_run
        @configuration.configure_mock_framework
        @world.announce_inclusion_filter

        @configuration.reporter.report(example_count) do |reporter|
          begin
            @configuration.run_hook(:before, :suite)
            example_groups.run_examples(reporter)
          ensure
            @configuration.run_hook(:after, :suite)
          end
        end

        example_groups.success?
      end

    private

      def example_count
        @world.example_count
      end

      module ExampleGroups
        def run_examples(reporter)
          @success = self.inject(true) {|success, group| success &= group.run(reporter)}
        end

        def success?
          @success ||= false
        end
      end

      def example_groups
        @world.example_groups.extend(ExampleGroups)
      end
    end
  end
end
Something went wrong with that request. Please try again.