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.



9
10
11
12
13
14
15
16
# File 'lib/runyoufools/runner.rb', line 9

def initialize( options )
       @options = options
       @tests = []
       find_tests
	Runyoufools.log :info, "found #{@tests.count} tests:"
	PP.pp @tests
	@results = { fail: [], pass: [] }
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

Instance Method Details

#find_testsObject



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

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

#goObject



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

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



39
40
41
# File 'lib/runyoufools/runner.rb', line 39

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

#successObject



43
44
45
# File 'lib/runyoufools/runner.rb', line 43

def success
    @success == true
end