class RSpec::Core::RakeTask

@see Rakefile
Rspec rake task

def blank

def blank
  lambda { |s| s.nil? || s == "" }
end

def define(args, &task_block)

Other tags:
    Private: -
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

def file_exclusion_specification

def file_exclusion_specification
  " --exclude-pattern #{exclude_pattern.shellescape}" if exclude_pattern
end

def file_inclusion_specification

def file_inclusion_specification
  if ENV['SPEC']
    FileList[ ENV['SPEC']].sort
  elsif File.exist?(pattern)
    # The provided pattern is a directory or a file, not a file glob. Historically, this
    # worked because `FileList[some_dir]` would return `[some_dir]` which would
    # get passed to `rspec` and cause it to load files under that dir that match
    # the default pattern. To continue working, we need to pass it on to `rspec`
    # directly rather than treating it as a `--pattern` option.
    #
    # TODO: consider deprecating support for this and removing it in RSpec 4.
    pattern.shellescape
  else
    "--pattern #{pattern.shellescape}"
  end
end

def initialize(*args, &task_block)

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

def rspec_load_path

def rspec_load_path
  @rspec_load_path ||= begin
    core_and_support = $LOAD_PATH.grep(
      /#{File::SEPARATOR}rspec-(core|support)[^#{File::SEPARATOR}]*#{File::SEPARATOR}lib/
    )
    "-I#{core_and_support.map(&:shellescape).join(File::PATH_SEPARATOR)}"
  end
end

def run_task(verbose)

Other tags:
    Private: -
def run_task(verbose)
  command = spec_command
  begin
    puts command if verbose
    success = system(command)
  rescue
    puts failure_message if failure_message
  end
  return unless fail_on_error && !success
  $stderr.puts "#{command} failed"
  exit $?.exitstatus
end

def spec_command

def spec_command
  cmd_parts = []
  cmd_parts << RUBY
  cmd_parts << ruby_opts
  cmd_parts << rspec_load_path
  cmd_parts << rspec_path
  cmd_parts << file_inclusion_specification
  cmd_parts << file_exclusion_specification
  cmd_parts << rspec_opts
  cmd_parts.flatten.reject(&blank).join(" ")
end