Class: Runyoufools::Runner

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

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/runyoufools/runner.rb', line 8

def initialize( options )
       @options = options
       @tests = []
       find_tests
  Runyoufools.log :info, "found #{@tests.count} tests:"
  @tests.each do |test| 
           puts test
       end
       exit( 0 ) if options.list
  @results = { fail: [], pass: [] }
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



6
7
8
# File 'lib/runyoufools/runner.rb', line 6

def results
  @results
end

Instance Method Details

#find_testsObject



20
21
22
23
24
25
26
27
28
# File 'lib/runyoufools/runner.rb', line 20

def find_tests
    Find.find('.') do |path|
        if @options.pattern.match( path )
            if File.file?( path )
                @tests.push( path )
            end
        end
    end
end

#goObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/runyoufools/runner.rb', line 30

def go
  @success = true
  @tests.each do |testFile|
    test = Test.new( testFile, @options.retries, @options.command )
    test.run
    key = test.ok ? :pass : :fail
    @results[ key ].push( test )
    @success = @success && test.ok
  end
end

#messageObject



41
42
43
# File 'lib/runyoufools/runner.rb', line 41

def message
  { true => 'OK', false => 'FAIL' }[ @success ]
end

#successObject



45
46
47
# File 'lib/runyoufools/runner.rb', line 45

def success
    @success == true
end