Rspec rake task
@see Rakefile
Default pattern for spec files.
Default path to the rspec executable
A message to print to stderr when there are failures.
Name of task.
default:
:spec
Glob pattern to match files.
default:
'spec /*_spec.rb'
Command line options to pass to rspec.
default:
nil
Path to rspec
default:
'rspec'
Command line options to pass to ruby.
default:
nil
Use verbose output. If this is set to true, the task will print the executed spec command to stdout.
default:
true
# File lib/rspec/core/rake_task.rb, line 69 def initialize(*args, &task_block) @name = args.shift || :spec @ruby_opts = nil @rspec_opts = nil @verbose = true @fail_on_error = true @rspec_path = DEFAULT_RSPEC_PATH @pattern = DEFAULT_PATTERN define(args, &task_block) end
@private
# File lib/rspec/core/rake_task.rb, line 82 def run_task(verbose) command = spec_command begin puts command if verbose success = system(command) rescue puts failure_message if failure_message end if fail_on_error && !success $stderr.puts "#{command} failed" exit $?.exitstatus end end
# File lib/rspec/core/rake_task.rb, line 130 def blank lambda {|s| s.nil? || s == ""} end
@private
# File lib/rspec/core/rake_task.rb, line 100 def define(args, &task_block) desc "Run RSpec code examples" unless ::Rake.application.last_comment task name, *args do |_, task_args| RakeFileUtils.__send__(:verbose, verbose) do task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block run_task verbose end end end
# File lib/rspec/core/rake_task.rb, line 111 def files_to_run if ENV['SPEC'] FileList[ ENV['SPEC'] ].sort else FileList[ pattern ].sort.map(&:shellescape) end end
# File lib/rspec/core/rake_task.rb, line 134 def rspec_load_path @rspec_load_path ||= begin core_and_support = $LOAD_PATH.grep %r{#{File::SEPARATOR}rspec-(core|support)[^#{File::SEPARATOR}]*#{File::SEPARATOR}lib} "-I#{core_and_support.map(&:shellescape).join(File::PATH_SEPARATOR)}" end end
# File lib/rspec/core/rake_task.rb, line 119 def spec_command cmd_parts = [] cmd_parts << RUBY cmd_parts << ruby_opts cmd_parts << rspec_load_path cmd_parts << "-S" << rspec_path cmd_parts << files_to_run cmd_parts << rspec_opts cmd_parts.flatten.reject(&blank).join(" ") end