Skip to content

Commit

Permalink
Merge pull request #47 from tevio/master
Browse files Browse the repository at this point in the history
Fix example group issue with turnip
  • Loading branch information
ArturT committed Oct 7, 2016
2 parents d7512be + b1e727f commit bf6b6ca
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 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

0 comments on commit bf6b6ca

Please sign in to comment.