Skip to content

Commit

Permalink
fix example group issue with turnip
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Martin committed Oct 3, 2016
1 parent 4c90e5e commit 70358ce
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
8 changes: 7 additions & 1 deletion lib/knapsack/adapters/rspec_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/knapsack/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Knapsack
VERSION = '1.12.1'
VERSION = '1.12.2'
end
40 changes: 31 additions & 9 deletions spec/knapsack/adapters/rspec_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 turnip is less than version 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.9) }

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-1.2.4/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) }

subject { described_class.test_path(current_example_metadata) }

it { should eql './spec/features/logging_in.feature' }
end
end
end
end

0 comments on commit 70358ce

Please sign in to comment.