class RSpec::Core::RakeTask
def blank
def blank lambda {|s| s.nil? || s == ""} end
def files_to_run
def files_to_run if ENV['SPEC'] FileList[ ENV['SPEC'] ].sort else FileList[ pattern ].sort.map { |f| shellescape(f) } end end
def gemfile=(*)
def gemfile=(*) RSpec.deprecate("RSpec::Core::RakeTask#gemfile=", 'ENV["BUNDLE_GEMFILE"]') end
def has_files?
def has_files? empty = files_to_run.empty? puts "No examples matching #{pattern} could be found" if empty not empty end
def initialize(*args, &task_block)
def initialize(*args, &task_block) setup_ivars(args) 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
def run_task(verbose)
def run_task(verbose) files = has_files? if files command = spec_command begin puts command if verbose success = system(command) rescue puts failure_message if failure_message end raise("#{command} failed") if fail_on_error unless success end end
def runner
def runner rcov ? rcov_path : rspec_path end
def setup_ivars(args)
def setup_ivars(args) @name = args.shift || :spec @rcov_opts, @ruby_opts, @rspec_opts = nil, nil, nil @warning, @rcov = false, false @verbose, @fail_on_error = true, true @rcov_path = 'rcov' @rspec_path = 'rspec' @pattern = './spec{,/*/**}/*_spec.rb' end
def shellescape(string)
def shellescape(string) string.shellescape end
def shellescape(string)
def shellescape(string) string.gsub(/"/, '\"').gsub(/'/, "\\\\'") end
def skip_bundler=(*)
def skip_bundler=(*) RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=") end
def spec_command
def spec_command cmd_parts = [] cmd_parts << RUBY cmd_parts << ruby_opts cmd_parts << "-w" if @warning cmd_parts << "-S" << runner cmd_parts << "-Ispec:lib" << rcov_opts if rcov cmd_parts << files_to_run cmd_parts << "--" if rcov && rspec_opts cmd_parts << rspec_opts cmd_parts.flatten.reject(&blank).join(" ") end
def spec_opts=(opts)
def spec_opts=(opts) RSpec.deprecate('RSpec::Core::RakeTask#spec_opts=', 'rspec_opts=') @rspec_opts = opts end
def warning=(true_or_false)
def warning=(true_or_false) RSpec.deprecate("RSpec::Core::RakeTask#warning=", 'ruby_opts="-w"') @warning = true_or_false end