Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit ea70e4e

Browse files
committed
prepend 'bundle exec' in rake task
- Fixes #426.
1 parent e7bb363 commit ea70e4e

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Cucumber::Rake::Task.new(:cucumber)
2828
desc "Run all examples"
2929
RSpec::Core::RakeTask.new(:spec) do |t|
3030
t.rspec_opts = %w[--color]
31-
t.verbose = false
3231
end
3332

3433
if RUBY_VERSION.to_f == 1.8

features/command_line/rake_task.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Feature: rake task
2020
end
2121
"""
2222
When I run `rake`
23-
Then the stderr should contain "ruby -S rspec"
23+
Then the output should contain "ruby -S rspec"
2424
Then the exit status should be 0
2525

2626
Scenario: default options with failing spec (exit status is 1)

lib/rspec/core/rake_task.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env ruby
2-
31
require 'rspec/core'
42
require 'rspec/core/deprecation'
53
require 'rake'
@@ -133,11 +131,12 @@ def initialize(*args)
133131
puts "No examples matching #{pattern} could be found"
134132
else
135133
begin
136-
ruby(spec_command)
134+
puts spec_command if verbose
135+
success = system(spec_command)
137136
rescue
138137
puts failure_message if failure_message
139-
raise("ruby #{spec_command} failed") if fail_on_error
140138
end
139+
raise("ruby #{spec_command} failed") if fail_on_error unless success
141140
end
142141
end
143142
end
@@ -155,10 +154,12 @@ def files_to_run # :nodoc:
155154

156155
def spec_command
157156
@spec_command ||= begin
158-
cmd_parts = [ruby_opts]
157+
cmd_parts = []
158+
cmd_parts << "bundle exec" if gemfile? unless skip_bundler
159+
cmd_parts << RUBY
160+
cmd_parts << ruby_opts
159161
cmd_parts << "-w" if warning?
160162
cmd_parts << "-S"
161-
cmd_parts << "bundle exec" if gemfile? unless skip_bundler
162163
cmd_parts << runner
163164
if rcov
164165
cmd_parts << ["-Ispec#{File::PATH_SEPARATOR}lib", rcov_opts]

spec/rspec/core/rake_task_spec.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module RSpec::Core
55
describe RakeTask do
66
let(:task) { RakeTask.new }
77

8+
def ruby
9+
FileUtils::RUBY
10+
end
11+
812
before do
913
File.stub(:exist?) { false }
1014
end
@@ -26,7 +30,7 @@ def spec_command
2630

2731
context "default" do
2832
it "renders rspec" do
29-
spec_command.should =~ /^-S rspec/
33+
spec_command.should =~ /^#{ruby} -S rspec/
3034
end
3135
end
3236

@@ -60,7 +64,7 @@ def spec_command
6064
context "with rcov" do
6165
it "renders rcov" do
6266
with_rcov do
63-
spec_command.should =~ /^-S rcov/
67+
spec_command.should =~ /^#{ruby} -S rcov/
6468
end
6569
end
6670
end
@@ -69,7 +73,7 @@ def spec_command
6973
it "renders bundle exec rcov" do
7074
with_bundler do
7175
with_rcov do
72-
spec_command.should =~ /^-S bundle exec rcov/
76+
spec_command.should =~ /^bundle exec #{ruby} -S rcov/
7377
end
7478
end
7579
end
@@ -78,7 +82,7 @@ def spec_command
7882
context "with ruby options" do
7983
it "renders them before -S" do
8084
task.ruby_opts = "-w"
81-
spec_command.should =~ /^-w -S rspec/
85+
spec_command.should =~ /^#{ruby} -w -S rspec/
8286
end
8387
end
8488

0 commit comments

Comments
 (0)