Class: Guard::Test::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Runner

Returns a new instance of Runner.



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

def initialize(opts = {})
  @options = {
    bundler:  File.exist?("#{Dir.pwd}/Gemfile"),
    rubygems: false,
    rvm:      [],
    include:  %w[lib:test],
    drb:      false,
    zeus:     false,
    spring:   false,
    cli:      ''
  }.merge(opts)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/guard/test/runner.rb', line 7

def options
  @options
end

Instance Method Details

#bundler?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
# File 'lib/guard/test/runner.rb', line 30

def bundler?
  if @bundler.nil?
    @bundler = options[:bundler] && !drb? && !zeus? && !spring?
  end
  @bundler
end

#drb?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/guard/test/runner.rb', line 41

def drb?
  if @drb.nil?
    @drb = options[:drb]
    begin
      require 'spork-testunit'
    rescue LoadError
    end
    Compat::UI.info('Using testdrb to run the tests') if @drb
  end
  @drb
end

#rubygems?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/guard/test/runner.rb', line 37

def rubygems?
  !bundler? && !zeus? && !spring? && options[:rubygems]
end

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



22
23
24
25
26
27
28
# File 'lib/guard/test/runner.rb', line 22

def run(paths, opts = {})
  return true if paths.empty?

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

  system(test_unit_command(paths))
end

#spring?Boolean

Returns:

  • (Boolean)


61
62
63
64
65
66
67
# File 'lib/guard/test/runner.rb', line 61

def spring?
  if @spring.nil?
    @spring = options[:spring]
    Compat::UI.info('Using spring to run the tests') if @spring
  end
  @spring
end

#zeus?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
# File 'lib/guard/test/runner.rb', line 53

def zeus?
  if @zeus.nil?
    @zeus = options[:zeus]
    Compat::UI.info('Using zeus to run the tests') if @zeus
  end
  @zeus
end