Sha256: f10522470d9b4ff8055fb87367f6da922d06b3aca1d0c25984af812751473004

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

module Petitest
  class TestCasesRunner
    # @return [Array<Petitest::TestCase>]
    attr_reader :test_cases

    # @param test_cases [Array<Petitest::TestCase>]
    def initialize(test_cases)
      @test_cases = test_cases
    end

    # @return [Boolean]
    def run
      before_running_test_cases(test_cases)
      test_cases.each do |test_case|
        before_running_test_case(test_case)
        test_case.run
        after_running_test_case(test_case)
      end
      after_running_test_cases(test_cases)
      test_cases.all?(&:passed?)
    end

    private

    # @param test_case [Petitest::TestCase]
    def after_running_test_case(test_case)
      subscribers.each do |subscriber|
        subscriber.after_running_test_case(test_case)
      end
    end

    # @param test_cases [Array<Petitest::TestCase>]
    def after_running_test_cases(test_cases)
      subscribers.each do |subscriber|
        subscriber.after_running_test_cases(test_cases)
      end
    end

    # @param test_case [Petitest::TestCase]
    def before_running_test_case(test_case)
      subscribers.each do |subscriber|
        subscriber.before_running_test_case(test_case)
      end
    end

    # @param test_cases [Array<Petitest::TestCase>]
    def before_running_test_cases(test_cases)
      subscribers.each do |subscriber|
        subscriber.before_running_test_cases(test_cases)
      end
    end

    # @return [Array<Petitest::Subscribers::BaseSubscriber>]
    def subscribers
      ::Petitest.configuration.subscribers
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
petitest-0.2.0 lib/petitest/test_cases_runner.rb
petitest-0.1.3 lib/petitest/test_cases_runner.rb
petitest-0.1.2 lib/petitest/test_cases_runner.rb
petitest-0.1.1 lib/petitest/test_cases_runner.rb
petitest-0.1.0 lib/petitest/test_cases_runner.rb