Parent

Files

Guard::RSpec::Runner

Constants

FAILURE_EXIT_CODE

Attributes

options[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/guard/rspec/runner.rb, line 12
def initialize(options = {})
  @options = {
    :bundler      => true,
    :binstubs     => false,
    :rvm          => nil,
    :cli          => nil,
    :env          => nil,
    :notification => true,
    :spring       => false,
    :turnip       => false,
    :zeus         => false,
    :foreman      => false
  }.merge(options)

  unless ENV['SPEC_OPTS'].nil?
    UI.warning "The SPEC_OPTS environment variable is present. This can conflict with guard-rspec, particularly notifications."
  end

  if options[:bundler] && !options[:binstubs]
    if options[:zeus]
      UI.warning "Running Zeus within bundler is waste of time. Bundler option is set to false, when using Zeus."
    elsif options[:spring]
      UI.warning "Running Spring within bundler is waste of time. Bundler option is set to false, when using Spring."
    end
  end

  deprecations_warnings
end

Public Instance Methods

failure_exit_code_supported?() click to toggle source
# File lib/guard/rspec/runner.rb, line 61
def failure_exit_code_supported?
  @failure_exit_code_supported ||= begin
    cmd_parts = []
    cmd_parts << "bundle exec" if bundle_exec?
    cmd_parts << rspec_executable
    cmd_parts << "--help"
    `#{cmd_parts.join(' ')}`.include? "--failure-exit-code"
  end
end
parsed_or_default_formatter() click to toggle source
# File lib/guard/rspec/runner.rb, line 71
def parsed_or_default_formatter
  @parsed_or_default_formatter ||= begin
    # Use RSpec's parser to parse formatters
    formatters = ::RSpec::Core::ConfigurationOptions.new([]).parse_options()[:formatters]
    # Use a default formatter if none exists.
    # RSpec's parser returns an array in the format [[formatter, output], ...], so match their format
    formatters = [['progress']] if formatters.nil? || formatters.empty?
    # Construct a matching command line option, including output target
    formatters.map { |formatter| "-f #{formatter.join ' -o '}" }.join ' '
  end
end
rspec_executable(runtime_options = {}) click to toggle source
# File lib/guard/rspec/runner.rb, line 56
def rspec_executable(runtime_options = {})
  command = parallel?(runtime_options) ? 'parallel_rspec' : 'rspec'
  @rspec_executable ||= (binstubs? && !executable_prefix?) ? "#{binstubs}/#{command}" : command
end
run(paths, options = {}) click to toggle source
# File lib/guard/rspec/runner.rb, line 41
def run(paths, options = {})
  return false if paths.empty?

  message = options[:message] || "Running: #{paths.join(' ')}"
  UI.info(message, :reset => true)

  options = @options.merge(options)

  if drb_used?
    run_via_drb(paths, options)
  else
    run_via_shell(paths, options)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.