Skip to content

Commit

Permalink
prepend 'bundle exec' in rake task
Browse files Browse the repository at this point in the history
- Fixes rspec#426.
  • Loading branch information
dchelimsky committed Jul 17, 2011
1 parent e7bb363 commit ea70e4e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -28,7 +28,6 @@ Cucumber::Rake::Task.new(:cucumber)
desc "Run all examples"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
t.verbose = false
end

if RUBY_VERSION.to_f == 1.8
Expand Down
2 changes: 1 addition & 1 deletion features/command_line/rake_task.feature
Expand Up @@ -20,7 +20,7 @@ Feature: rake task
end
"""
When I run `rake`
Then the stderr should contain "ruby -S rspec"
Then the output should contain "ruby -S rspec"
Then the exit status should be 0

Scenario: default options with failing spec (exit status is 1)
Expand Down
13 changes: 7 additions & 6 deletions lib/rspec/core/rake_task.rb
@@ -1,5 +1,3 @@
#!/usr/bin/env ruby

require 'rspec/core'
require 'rspec/core/deprecation'
require 'rake'
Expand Down Expand Up @@ -133,11 +131,12 @@ def initialize(*args)
puts "No examples matching #{pattern} could be found"
else
begin
ruby(spec_command)
puts spec_command if verbose
success = system(spec_command)
rescue
puts failure_message if failure_message
raise("ruby #{spec_command} failed") if fail_on_error
end
raise("ruby #{spec_command} failed") if fail_on_error unless success
end
end
end
Expand All @@ -155,10 +154,12 @@ def files_to_run # :nodoc:

def spec_command
@spec_command ||= begin
cmd_parts = [ruby_opts]
cmd_parts = []
cmd_parts << "bundle exec" if gemfile? unless skip_bundler
cmd_parts << RUBY
cmd_parts << ruby_opts
cmd_parts << "-w" if warning?
cmd_parts << "-S"
cmd_parts << "bundle exec" if gemfile? unless skip_bundler
cmd_parts << runner
if rcov
cmd_parts << ["-Ispec#{File::PATH_SEPARATOR}lib", rcov_opts]
Expand Down
12 changes: 8 additions & 4 deletions spec/rspec/core/rake_task_spec.rb
Expand Up @@ -5,6 +5,10 @@ module RSpec::Core
describe RakeTask do
let(:task) { RakeTask.new }

def ruby
FileUtils::RUBY
end

before do
File.stub(:exist?) { false }
end
Expand All @@ -26,7 +30,7 @@ def spec_command

context "default" do
it "renders rspec" do
spec_command.should =~ /^-S rspec/
spec_command.should =~ /^#{ruby} -S rspec/
end
end

Expand Down Expand Up @@ -60,7 +64,7 @@ def spec_command
context "with rcov" do
it "renders rcov" do
with_rcov do
spec_command.should =~ /^-S rcov/
spec_command.should =~ /^#{ruby} -S rcov/
end
end
end
Expand All @@ -69,7 +73,7 @@ def spec_command
it "renders bundle exec rcov" do
with_bundler do
with_rcov do
spec_command.should =~ /^-S bundle exec rcov/
spec_command.should =~ /^bundle exec #{ruby} -S rcov/
end
end
end
Expand All @@ -78,7 +82,7 @@ def spec_command
context "with ruby options" do
it "renders them before -S" do
task.ruby_opts = "-w"
spec_command.should =~ /^-w -S rspec/
spec_command.should =~ /^#{ruby} -w -S rspec/
end
end

Expand Down

0 comments on commit ea70e4e

Please sign in to comment.