Class: Guard::FastSpec::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/fast_spec/runner.rb

Constant Summary collapse

FAILURE_EXIT_CODE =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/guard/fast_spec/runner.rb', line 8

def initialize(options = {})
  @options = {
    :bundler      => true,
    :binstubs     => false,
    :rvm          => nil,
    :cli          => nil,
    :notification => true
  }.merge(options)

  deprecations_warnings
end

Instance Attribute Details

#fast_spec_versionObject (readonly)

Returns the value of attribute fast_spec_version.



4
5
6
# File 'lib/guard/fast_spec/runner.rb', line 4

def fast_spec_version
  @fast_spec_version
end

Instance Method Details

#failure_exit_code_supported?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
# File 'lib/guard/fast_spec/runner.rb', line 46

def failure_exit_code_supported?
  @failure_exit_code_supported ||= begin
    cmd_parts = []
    cmd_parts << "bundle exec" if bundler?
    cmd_parts << fast_spec_executable
    cmd_parts << "--help"
    `#{cmd_parts.join(' ')}`.include? "--failure-exit-code"
  end
end

#fast_spec_classObject



56
57
58
59
60
61
62
63
# File 'lib/guard/fast_spec/runner.rb', line 56

def fast_spec_class
  @fast_spec_class ||= case fast_spec_version
                   when 1
                     "Spec"
                   when 2
                     "RSpec"
                   end
end

#fast_spec_executableObject



39
40
41
42
43
44
# File 'lib/guard/fast_spec/runner.rb', line 39

def fast_spec_executable
  @fast_spec_executable ||= begin
    exec = fast_spec_class.downcase
    binstubs? ? "bin/#{exec}" : exec
  end
end

#run(paths, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/guard/fast_spec/runner.rb', line 20

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