Sha256: d70e152d2ebe28e20dcc8a4328a4adbd6849ea173dffbbe302516bdd9f1c849b

Contents?: true

Size: 1.34 KB

Versions: 92

Compression:

Stored size: 1.34 KB

Contents

describe KnapsackPro::TestFilePattern do
  describe '.call' do
    let(:adapter_class) { KnapsackPro::Adapters::BaseAdapter }

    subject { described_class.call(adapter_class) }

    before do
      expect(KnapsackPro::Config::Env).to receive(:test_file_pattern).and_return(env_test_file_pattern)
    end

    context 'when ENV defined' do
      let(:env_test_file_pattern) { 'spec/**{,/*/**}/*_spec.rb' }

      it { should eq env_test_file_pattern }
    end

    context 'when ENV not defined' do
      let(:env_test_file_pattern) { nil }

      it { should eq 'test/**{,/*/**}/*_test.rb' }
    end
  end

  describe '#test_dir' do
    let(:adapter_class) { KnapsackPro::Adapters::BaseAdapter }

    subject { described_class.test_dir(adapter_class) }

    before do
      expect(described_class).to receive(:call).with(adapter_class).and_return(test_file_pattern)
    end

    context 'when default test file pattern' do
      let(:test_file_pattern) { 'spec/**{,/*/**}/*_spec.rb' }

      it 'extracts test directory from the pattern' do
        expect(subject).to eq 'spec'
      end
    end

    context 'when test file pattern has multiple patterns' do
      let(:test_file_pattern) { '{spec/*_spec.rb,spec2/controllers/**/*_spec.rb}' }

      it 'extracts test directory from the first pattern' do
        expect(subject).to eq 'spec'
      end
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
knapsack_pro-7.13.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.12.1 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.12.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.11.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.10.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.9.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.8.2 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.8.1 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.8.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.7.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.6.2 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.6.1 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.6.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.1.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.0.1 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-7.0.0 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-6.0.4 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-6.0.3 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-6.0.2 spec/knapsack_pro/test_file_pattern_spec.rb
knapsack_pro-6.0.1 spec/knapsack_pro/test_file_pattern_spec.rb