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 for bundler path issue in Cucumber Rake task #386 #388

Closed
wants to merge 4 commits into from
Closed
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: 8 additions & 4 deletions lib/cucumber/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files)
end

def load_path(libs)
['"%s"' % @libs.join(File::PATH_SEPARATOR)]
['"%s"' % libs.join(File::PATH_SEPARATOR)]
end

def quoted_binary(cucumber_bin)
Expand All @@ -78,6 +78,11 @@ def use_bundler
@bundler.nil? ? File.exist?("./Gemfile") && gem_available?("bundler") : @bundler
end

def bundler_lib_path
spec = Gem::Specification.find_by_name('bundler')
File.join(spec.gem_dir , 'lib')
end

def gem_available?(gemname)
gem_available_new_rubygems?(gemname) || gem_available_old_rubygems?(gemname)
end
Expand All @@ -92,8 +97,7 @@ def gem_available_new_rubygems?(gemname)

def cmd
if use_bundler
bundle_cmd = Gem.default_exec_format % 'bundle'
[ Cucumber::RUBY_BINARY, '-S', bundle_cmd, 'exec', 'cucumber', @cucumber_opts,
[ Cucumber::RUBY_BINARY, '-I', load_path([bundler_lib_path] + @libs), '-rbundler/setup', quoted_binary(@cucumber_bin), @cucumber_opts,
@feature_files ].flatten
else
[ Cucumber::RUBY_BINARY, '-I', load_path(@libs), quoted_binary(@cucumber_bin),
Expand All @@ -115,7 +119,7 @@ def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files, rcov_o

def cmd
if use_bundler
[Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'rcov', @rcov_opts,
[Cucumber::RUBY_BINARY, '-I', load_path([bundler_lib_path] + @libs), '-rbundler/setup', '-S', 'rcov', @rcov_opts,
quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
else
[Cucumber::RUBY_BINARY, '-I', load_path(@libs), '-S', 'rcov', @rcov_opts,
Expand Down
25 changes: 8 additions & 17 deletions spec/cucumber/rake/forked_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Rake
context "when running with bundler" do

let(:bundler) { true }
let(:bundler_lib_dir) { File.join(Gem.dir, 'gems', 'bundler-1.2.3', 'lib') }
let(:bundler_spec) { Gem::Specification.new 'bundler', '1.2.3' }

subject { Task::ForkedCucumberRunner.new(
libs, binary, cucumber_opts, bundler, feature_files) }
Expand All @@ -23,25 +25,14 @@ module Rake
subject.use_bundler.should be_true
end

it "uses bundle exec to find cucumber and libraries" do
bundle_cmd = Gem.default_exec_format % 'bundle'
it "uses bundler to find cucumber and libraries" do
Gem::Specification.should_receive(:find_by_name).with('bundler').and_return(bundler_spec)

subject.cmd.should == [Cucumber::RUBY_BINARY,
'-S',
bundle_cmd,
'exec',
'cucumber',
'--cuke-option'] + feature_files
end

it "obeys program suffix for bundler" do
Gem::ConfigMap.stub(:[]).with(:ruby_install_name).and_return('XrubyY')

subject.cmd.should == [Cucumber::RUBY_BINARY,
'-S',
'XbundleY',
'exec',
'cucumber',
'-I',
'"%s"' % ([bundler_lib_dir]+libs).join(File::PATH_SEPARATOR),
'-rbundler/setup',
"\"#{Cucumber::BINARY }\"",
'--cuke-option'] + feature_files
end

Expand Down
11 changes: 8 additions & 3 deletions spec/cucumber/rake/rcov_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module Rake
context "when running with bundler" do

let(:bundler) { true }
let(:bundler_lib_dir) { File.join(Gem.dir, 'gems', 'bundler-1.2.3', 'lib') }
let(:bundler_spec) { Gem::Specification.new 'bundler', '1.2.3' }

subject { Task::RCovCucumberRunner.new(
libs, binary, cucumber_opts, bundler, feature_files, rcov_opts) }
Expand All @@ -25,11 +27,14 @@ module Rake
subject.use_bundler.should be_true
end

it "uses bundle exec to find cucumber and libraries" do
it "uses bundler to find cucumber and libraries" do
Gem::Specification.should_receive(:find_by_name).with('bundler').and_return(bundler_spec)

subject.cmd.should == [Cucumber::RUBY_BINARY,
'-I',
'"%s"' % ([bundler_lib_dir]+libs).join(File::PATH_SEPARATOR),
'-rbundler/setup',
'-S',
'bundle',
'exec',
'rcov',
'--rcov-option',
"\"#{Cucumber::BINARY }\"",
Expand Down