Sha256: e44bb17140416744e3f494dee741c7e1adfd941d5102c47e365ced6185300ec0

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

module RR
  class << self
    ADAPTER_NAMES = [
      :RSpec1,
      :RSpec2,
      :TestUnit1,
      :TestUnit2ActiveSupport,
      :TestUnit2,
      :MiniTestActiveSupport,
      :MiniTest
    ]

    def autohook
      find_applicable_adapters.each do |adapter|
        #puts "Using adapter: #{adapter.name}"
        adapter.hook
      end
    end

    private

    def adapters
      @adapters ||= ADAPTER_NAMES.map { |adapter_name|
        [adapter_name, RR::Adapters.const_get(adapter_name).new]
      }
    end

    def find_applicable_adapters
      @applicable_adapters ||= begin
        applicable_adapters = adapters.inject([]) { |arr, (_, adapter)|
          arr << adapter if adapter.applies?
          arr
        }
        if applicable_adapters.empty?
          applicable_adapters << adapters.index(:None)
        end
        applicable_adapters
      end
    end
  end
end

RR.autohook

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rr-1.1.0.rc1 lib/rr/autohook.rb