diff --git a/lib/knapsack/adapters/rspec_adapter.rb b/lib/knapsack/adapters/rspec_adapter.rb index 1f21d25..e6e7f89 100644 --- a/lib/knapsack/adapters/rspec_adapter.rb +++ b/lib/knapsack/adapters/rspec_adapter.rb @@ -48,7 +48,13 @@ def bind_time_offset_warning end def self.test_path(example_group) - unless example_group[:turnip] + if defined?(Turnip) && Turnip::VERSION.to_i < 2 + unless example_group[:turnip] + until example_group[:parent_example_group].nil? + example_group = example_group[:parent_example_group] + end + end + else until example_group[:parent_example_group].nil? example_group = example_group[:parent_example_group] end diff --git a/lib/knapsack/version.rb b/lib/knapsack/version.rb index 059d79e..6d399d5 100644 --- a/lib/knapsack/version.rb +++ b/lib/knapsack/version.rb @@ -1,3 +1,3 @@ module Knapsack - VERSION = '1.12.1' + VERSION = '1.12.2' end diff --git a/spec/knapsack/adapters/rspec_adapter_spec.rb b/spec/knapsack/adapters/rspec_adapter_spec.rb index 89e39a8..a4ec31a 100644 --- a/spec/knapsack/adapters/rspec_adapter_spec.rb +++ b/spec/knapsack/adapters/rspec_adapter_spec.rb @@ -98,19 +98,41 @@ it { should eql 'a_spec.rb' } context 'with turnip features' do - let(:current_example_metadata) do - { - file_path: "./spec/features/logging_in.feature", - turnip: true, - parent_example_group: { - file_path: "gems/turnip-1.2.4/lib/turnip/rspec.rb", + describe 'when the turnip version is less than 2' do + let(:current_example_metadata) do + { + file_path: "./spec/features/logging_in.feature", + turnip: true, + parent_example_group: { + file_path: "gems/turnip-1.2.4/lib/turnip/rspec.rb" + } } - } + end + + before { stub_const("Turnip::VERSION", '1.2.4') } + + subject { described_class.test_path(current_example_metadata) } + + it { should eql './spec/features/logging_in.feature' } end - subject { described_class.test_path(current_example_metadata) } + describe 'when turnip is version 2 or greater' do + let(:current_example_metadata) do + { + file_path: "gems/turnip-2.0.0/lib/turnip/rspec.rb", + turnip: true, + parent_example_group: { + file_path: "./spec/features/logging_in.feature", + } + } + end - it { should eql './spec/features/logging_in.feature' } + before { stub_const("Turnip::VERSION", '2.0.0') } + + subject { described_class.test_path(current_example_metadata) } + + it { should eql './spec/features/logging_in.feature' } + end end end end