Sha256: 44ea44139b11bed47f9be335239968a45412b7e8349f26815fae29d6e0d6b71e

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

module RSpec
  module Core
    class CommandLine
      def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
        if Array === options
          options = ConfigurationOptions.new(options)
          options.parse_options
        end
        @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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-core-2.0.0.beta.19 lib/rspec/core/command_line.rb
rspec-core-2.0.0.beta.18 lib/rspec/core/command_line.rb
rspec-core-2.0.0.beta.17 lib/rspec/core/command_line.rb