Sha256: 75a1df7716d73ecfd596b5ed4dd2b3385afa123dcaf45552e405243c95ee7a65

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

module KnapsackPro
  class BaseAllocatorBuilder
    TEST_RUNNER_MAP = {
      KnapsackPro::Adapters::RSpecAdapter => 'rspec',
      KnapsackPro::Adapters::CucumberAdapter => 'cucumber',
      KnapsackPro::Adapters::MinitestAdapter => 'minitest',
      KnapsackPro::Adapters::SpinachAdapter => 'spinach',
      KnapsackPro::Adapters::TestUnitAdapter => 'test-unit',
    }

    def initialize(adapter_class)
      @adapter_class = adapter_class
      ENV['KNAPSACK_PRO_TEST_RUNNER'] = TEST_RUNNER_MAP[adapter_class]
    end

    def allocator
      raise NotImplementedError
    end

    def test_dir
      KnapsackPro::Config::Env.test_dir || test_file_pattern.split('/').first.gsub(/({)/, '')
    end

    private

    attr_reader :adapter_class

    def env
      KnapsackPro::Config::Env
    end

    def repository_adapter
      KnapsackPro::RepositoryAdapterInitiator.call
    end

    def test_file_pattern
      TestFilePattern.call(adapter_class)
    end

    def test_files
      KnapsackPro::TestFileFinder.call(test_file_pattern)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
knapsack_pro-1.18.2 lib/knapsack_pro/base_allocator_builder.rb
knapsack_pro-1.18.1 lib/knapsack_pro/base_allocator_builder.rb
knapsack_pro-1.18.0 lib/knapsack_pro/base_allocator_builder.rb
knapsack_pro-1.17.0 lib/knapsack_pro/base_allocator_builder.rb
knapsack_pro-1.16.1 lib/knapsack_pro/base_allocator_builder.rb
knapsack_pro-1.16.0 lib/knapsack_pro/base_allocator_builder.rb