Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example group issue with turnip #47

Merged
merged 1 commit into from
Oct 7, 2016
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to still have backward compatibility with Turnip 1.x

You could check if Turnip exists and if the version is bellow 2.x then follow old approach.

if defined?(Turnip) && Turnip::VERSION.to_i < 2

and we need test for both cases.

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 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