Browse files

Added the ability to specify a "rcov_path" in the rake task, allowing…

… for paths such as "bundle exec rcov"
  • Loading branch information...
1 parent a2e8259 commit d72db59ead630bb184f1dab5895b5bfc0cd74c9c @spicycode spicycode committed Jun 18, 2010
Showing with 22 additions and 6 deletions.
  1. +22 −6 lib/rspec/core/rake_task.rb
View
28 lib/rspec/core/rake_task.rb
@@ -35,16 +35,20 @@ class RakeTask < ::Rake::TaskLib
# Use rcov for code coverage? defaults to false
attr_accessor :rcov
+ # Path to rcov. You can set this to 'bundle exec rcov' if you bundle rcov.
+ attr_accessor :rcov_path
+
# The options to pass to rcov. Defaults to blank
attr_accessor :rcov_opts
def initialize(*args)
@name = args.shift || :spec
- @pattern, @rcov_opts, @ruby_opts = nil, nil, nil
+ @pattern, @rcov_path, @rcov_opts, @ruby_opts = nil, nil, nil, nil
@warning, @rcov = false, false
@fail_on_error = true
yield self if block_given?
+ @rcov_path ||= 'rcov'
@pattern ||= './spec/**/*_spec.rb'
define
end
@@ -58,14 +62,17 @@ def define # :nodoc:
if files_to_run.empty?
puts "No examples matching #{pattern} could be found"
else
- cmd_parts = [rcov ? 'rcov' : RUBY]
- cmd_parts += rcov ? [rcov_opts] : [ruby_opts]
- cmd_parts << '-Ilib'
- cmd_parts << '-Ispec'
+ cmd_parts = [
+ runner,
+ runner_options,
+ '-Ilib',
+ '-Ispec'
+ ]
cmd_parts << "-w" if warning
- cmd_parts += files_to_run.collect { |fn| %["#{fn}"] }
+ cmd_parts += files_to_run.map { |fn| %["#{fn}"] }
cmd = cmd_parts.join(" ")
puts cmd if verbose
+
unless system(cmd)
STDERR.puts failure_message if failure_message
raise("Command #{cmd} failed") if fail_on_error
@@ -81,6 +88,15 @@ def files_to_run # :nodoc:
FileList[ pattern ].to_a
end
+ private
+ def runner
+ rcov ? rcov_path : RUBY
+ end
+
+ def runner_options
+ rcov ? [rcov_opts] : [ruby_opts]
+ end
+
end
end

0 comments on commit d72db59

Please sign in to comment.