Sha256: 02126b8ae9bbc74d84e645ebfc05d2c2226efdc4358687937796252fa0ec665b

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'pork/error'

module Pork
  class Runner < Struct.new(:suite, :seed, :stat, :desc, :test, :env)
    def run
      assertions = stat.assertions
      context = suite.new(stat, desc, [])

      stat.reporter.case_start(context)

      passed = protected do
        env.run_before(context)
        context.instance_eval(&test)
      end

      protected{ env.run_after(context) }

      if passed
        if assertions == stat.assertions
          protected{ raise Error.new('Missing assertions') }
        else
          stat.reporter.case_pass
        end
      end

      stat.incr_tests
      stat.reporter.case_end
    end

    private
    def protected
      yield
      true
    rescue *stat.protected_exceptions => e
      case e
      when Skip
        stat.incr_skips
        stat.reporter.case_skip
      else
        err = [e, suite.description_for("would #{desc}"), test, seed]
        case e
        when Failure
          stat.add_failure(err)
          stat.reporter.case_failed
        else
          stat.add_error(err)
          stat.reporter.case_errored
        end
      end
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pork-2.1.0 lib/pork/runner.rb