diff --git a/CHANGELOG.md b/CHANGELOG.md index eac65e87..12ea0464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ * TODO +### 0.43.0 + +* Extract correct test directory from test file pattern that has multiple patterns. + + https://github.com/KnapsackPro/knapsack_pro-ruby/pull/43 + +https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.42.0...v0.43.0 + ### 0.42.0 * Clear RSpec examples without shared examples in similar way as in RSpec 3.6.0 diff --git a/lib/knapsack_pro/base_allocator_builder.rb b/lib/knapsack_pro/base_allocator_builder.rb index 8f40a583..1ca05323 100644 --- a/lib/knapsack_pro/base_allocator_builder.rb +++ b/lib/knapsack_pro/base_allocator_builder.rb @@ -9,7 +9,7 @@ def allocator end def test_dir - test_file_pattern.split('/').first + test_file_pattern.split('/').first.gsub(/({)/, '') end private diff --git a/spec/knapsack_pro/base_allocator_builder_spec.rb b/spec/knapsack_pro/base_allocator_builder_spec.rb index 6d385303..c4bbba8e 100644 --- a/spec/knapsack_pro/base_allocator_builder_spec.rb +++ b/spec/knapsack_pro/base_allocator_builder_spec.rb @@ -14,9 +14,19 @@ subject { allocator_builder.test_dir } before do - expect(KnapsackPro::TestFilePattern).to receive(:call).with(adapter_class).and_return('spec/**{,/*/**}/*_spec.rb') + expect(KnapsackPro::TestFilePattern).to receive(:call).with(adapter_class).and_return(test_file_pattern) end - it { should eq 'spec' } + context 'when single pattern' do + let(:test_file_pattern) { 'spec/**{,/*/**}/*_spec.rb' } + + it { should eq 'spec' } + end + + context 'when multiple patterns' do + let(:test_file_pattern) { '{spec/controllers/**/*.rb,spec/decorators/**/*.rb}' } + + it { should eq 'spec' } + end end end