Sha256: 7b50b7c4f3c44d0696594ea6e12a74add21be20f50086d530b480a1e4a3e83bb

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

# This file is automatically required when you run `assert`; put any test
# helpers here.

# Add the root dir to the load path.
ROOT_PATH = File.expand_path("../..", __FILE__)
$LOAD_PATH.unshift(ROOT_PATH)

# require pry for debugging (`binding.pry`)
require "pry"
require "test/support/factory"

module Assert::Test::TestHelpers
  def self.included(receiver)
    receiver.class_eval do
      setup do
        @test_run_results = []
        @run_callback = proc{ |result| @test_run_results << result }
      end
    end

    private

    # rubocop:disable Lint/NestedMethodDefinition
    def test_run_callback
      @run_callback
    end

    def test_run_results(type = nil)
      return @test_run_results if type.nil?
      @test_run_results.select{ |r| r.type == type }
    end

    def test_run_result_count(type = nil)
      test_run_results(type).count
    end

    def test_run_result_messages
      @test_run_results.map(&:message)
    end

    def last_test_run_result
      @test_run_results.last
    end
    # rubocop:enable Lint/NestedMethodDefinition
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
assert-2.19.6 test/helper.rb
assert-2.19.5 test/helper.rb
assert-2.19.4 test/helper.rb
assert-2.19.3 test/helper.rb