Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

### 8.0.1

* Fix detection of id paths for Turnip, which resulted in sending to the API both file and id paths timings
* Example:
* turnip/acceptance/foo.feature[1:1:1] 0 seconds
* turnip/acceptance/foo.feature[1:1:2] 0 seconds
* turnip/acceptance/foo.feature 30 milliseconds (time recorded for [1:1:1] or [1:1:2])

https://github.com/KnapsackPro/knapsack_pro-ruby/pull/290

https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.0.0...v8.0.1

### 8.0.0

* Enable [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`](https://docs.knapsackpro.com/ruby/split-by-test-examples/) by default
Expand Down
6 changes: 4 additions & 2 deletions lib/knapsack_pro/adapters/rspec_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module KnapsackPro
module Adapters
class RSpecAdapter < BaseAdapter
TEST_DIR_PATTERN = 'spec/**{,/*/**}/*_spec.rb'
ID_PATH_REGEX = /.+_spec\.rb\[.+\]$/
# https://github.com/rspec/rspec/blob/86b5e4218eece4c1913fe9aad24c0a96d8bc9f40/rspec-core/lib/rspec/core/example.rb#L122
REGEX = /^(.*?)(?:\[([\d\s:,]+)\])?$/.freeze

def self.split_by_test_cases_enabled?
return false unless KnapsackPro::Config::Env.rspec_split_by_test_examples?
Expand Down Expand Up @@ -81,7 +82,8 @@ def self.parse_file_path(id)
end

def self.id_path?(path)
ID_PATH_REGEX.match?(path)
_file, id = path.match(REGEX).captures
!id.nil?
end

def self.rails_helper_exists?(test_dir)
Expand Down
24 changes: 21 additions & 3 deletions spec/knapsack_pro/adapters/rspec_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,41 @@
describe '.id_path?' do
subject { described_class.id_path?(path) }

context 'when the path resembles the RSpec path with id' do
context 'when the path is an RSpec path with id' do
let(:path) { 'spec/features/a_spec.rb[1:1:7:1]' }

it { is_expected.to be true }
end

context 'when the path resembles the RSpec path with multiple ids' do
context 'when the path is an RSpec path with multiple ids' do
let(:path) { 'spec/features/a_spec.rb[1:1:7:1, 1:2]' }

it { is_expected.to be true }
end

context "when the path doesn't resemble the RSpec path with id" do
context 'when the path is an RSpec path with no id' do
let(:path) { 'spec/features/a_spec.rb' }

it { is_expected.to be false }
end

context 'when the path is a Turnip path with id' do
let(:path) { 'spec/acceptance/a.feature[1:1:7:1]' }

it { is_expected.to be true }
end

context 'when the path is a Turnip path with multiple ids' do
let(:path) { 'spec/acceptance/a.feature[1:1:7:1,1:2]' }

it { is_expected.to be true }
end

context 'when the path is a Turnip path with no id' do
let(:path) { 'spec/acceptance/a.feature' }

it { is_expected.to be false }
end
end

describe '.rails_helper_exists?' do
Expand Down