class RSpec::Core::RakeTask

Attributes

fail_on_error[RW]

Whether or not to fail Rake when an error occurs (typically when examples fail).

default:

true
failure_message[RW]

A message to print to stderr when there are failures.

name[RW]

Name of task.

default:

:spec
pattern[RW]

Glob pattern to match files.

default:

'spec   /*_spec.rb'
rcov[RW]

Use rcov for code coverage?

default:

false
rcov_opts[RW]

Command line options to pass to rcov.

default:

nil
rcov_path[RW]

Path to rcov.

default:

'rcov'
rspec_opts[RW]

Command line options to pass to rspec.

default:

nil
rspec_path[RW]

Path to rspec

default:

'rspec'
ruby_opts[RW]

Command line options to pass to ruby.

default:

nil
verbose[RW]

Use verbose output. If this is set to true, the task will print the executed spec command to stdout.

default:

true

Public Class Methods

new(*args) { |self| ... } click to toggle source
# File lib/rspec/core/rake_task.rb, line 112
def initialize(*args)
  @name = args.shift || :spec
  @pattern, @rcov_path, @rcov_opts, @ruby_opts, @rspec_opts = nil, nil, nil, nil, nil
  @warning, @rcov = false, false
  @verbose, @fail_on_error = true, true

  yield self if block_given?

  @rcov_path  ||= 'rcov'
  @rspec_path ||= 'rspec'
  @pattern    ||= './spec{,/*/**}/*_spec.rb'

  desc("Run RSpec code examples") unless ::Rake.application.last_comment

  task name do
    RakeFileUtils.send(:verbose, verbose) do
      if files_to_run.empty?
        puts "No examples matching #{pattern} could be found"
      else
        begin
          puts spec_command if verbose
          success = system(spec_command)
        rescue
          puts failure_message if failure_message
        end
        raise("#{spec_command} failed") if fail_on_error unless success
      end
    end
  end
end

Public Instance Methods

gemfile=(*) click to toggle source

@deprecated Has no effect. The rake task now checks ENV instead.

# File lib/rspec/core/rake_task.rb, line 31
def gemfile=(*)
  RSpec.deprecate("RSpec::Core::RakeTask#gemfile=", 'ENV["BUNDLE_GEMFILE"]')
end
skip_bundler=(*) click to toggle source

@deprecated Has no effect. The rake task now checks ENV instead.

# File lib/rspec/core/rake_task.rb, line 25
def skip_bundler=(*)
  RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=")
end
spec_opts=(opts) click to toggle source

@deprecated Use #rspec_opts instead.

Command line options to pass to rspec.

default:

nil
# File lib/rspec/core/rake_task.rb, line 107
def spec_opts=(opts)
  RSpec.deprecate('RSpec::Core::RakeTask#spec_opts=', 'rspec_opts=')
  @rspec_opts = opts
end
warning=(true_or_false) click to toggle source

@deprecated Use #ruby_opts="-w" instead.

When true, requests that the specs be run with the warning flag set. e.g. "ruby -w"

default:

false
# File lib/rspec/core/rake_task.rb, line 43
def warning=(true_or_false)
  RSpec.deprecate("RSpec::Core::RakeTask#warning=", 'ruby_opts="-w"')
  @warning = true_or_false
end