Sha256: b1e42f3b19d9791b8978f267114793f1e84ed91a455e3fa23a4c5922e5c16b1a

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

module ::RSpec::Core
  class Runner

    # Runs the suite of specs and exits the process with an appropriate exit code.
    def self.invoke
      disable_autorun!
      # WAS:
      #   status = run(ARGV, $stderr, $stdout).to_i
      #   exit(status) if status != 0
      # NOW:
      run(ARGV, $stderr, $stdout).then do |status|
        status = status.to_i
        exit(status) if status != 0
      end
    end

    def run_specs(example_groups)
      @configuration.reporter.report(@world.example_count(example_groups)) do |reporter|
        hook_context = SuiteHookContext.new

        Promise.value(true).then do
          @configuration.hooks.run(:before, :suite, hook_context)

          # WAS: example_groups.map { |g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
          results = []
          example_groups.inject(Promise.value(true)) do |previous_promise, group|
            previous_promise.then do |result|
              results << result
              group.run reporter
            end
          end.then do |result|
            results << result
            results.all? ? 0 : @configuration.failure_exit_code
          end

        end.ensure do |result|
          @configuration.hooks.run(:after, :suite, hook_context)
          result
        end
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
opal-rspec-0.8.0 lib-opal/opal/rspec/async/runner.rb
opal-rspec-0.8.0.alpha3 lib-opal/opal/rspec/async/runner.rb
opal-rspec-0.8.0.alpha2 lib-opal/opal/rspec/async/runner.rb
opal-rspec-0.8.0.alpha1 lib-opal/opal/rspec/async/runner.rb
opal-rspec-0.7.1 lib-opal/opal/rspec/async/runner.rb
opal-rspec-0.7.0 lib-opal/opal/rspec/async/runner.rb
opal-rspec-0.7.0.rc.2 lib-opal/opal/rspec/async/runner.rb
opal-rspec-0.7.0.rc.1 lib-opal/opal/rspec/async/runner.rb