Sha256: b8d93c09a0f25d5a002f4e6dd730c2e55000ef845a51b45ce23a6e3f50203863

Contents?: true

Size: 822 Bytes

Versions: 1

Compression:

Stored size: 822 Bytes

Contents

# frozen_string_literal: true

require_relative("error")
require_relative("failure_group")

module AggregateAssertions
  # Main entry-point for the interacting with the state of aggregation.
  module AssertionAggregator
    class << self
      def active?
        !store.nil? && !store.empty?
      end

      def add_error(ex)
        store.last.add_error(ex)
      end

      def open_failure_group(label = nil)
        initialize_store << FailureGroup.new(label: label, location: location)
      end

      def close_failure_group
        store.pop
      end

      private

      def store
        Thread.current[:__mt_aggregate]
      end

      def initialize_store
        Thread.current[:__mt_aggregate] ||= []
      end

      def location
        caller(3, 1).first.sub(/:in .*$/, "")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggregate_assertions-0.1.0.pre0 lib/aggregate_assertions/assertion_aggregator.rb