Class: TestFileRunner

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, ignore_selenium) ⇒ TestFileRunner

Returns a new instance of TestFileRunner.



14
15
16
17
18
19
# File 'lib/test_file_runner.rb', line 14

def initialize(env, ignore_selenium)
  @repo = env[:repo]
  @shell = env[:shell]
  @test_runner = env[:test_runner]
  @ignore_selenium = ignore_selenium
end

Instance Attribute Details

#ignore_seleniumObject (readonly)

Returns the value of attribute ignore_selenium.



13
14
15
# File 'lib/test_file_runner.rb', line 13

def ignore_selenium
  @ignore_selenium
end

#repoObject (readonly)

Returns the value of attribute repo.



13
14
15
# File 'lib/test_file_runner.rb', line 13

def repo
  @repo
end

#shellObject (readonly)

Returns the value of attribute shell.



13
14
15
# File 'lib/test_file_runner.rb', line 13

def shell
  @shell
end

#test_runnerObject (readonly)

Returns the value of attribute test_runner.



13
14
15
# File 'lib/test_file_runner.rb', line 13

def test_runner
  @test_runner
end

#testsObject (readonly)

Returns the value of attribute tests.



13
14
15
# File 'lib/test_file_runner.rb', line 13

def tests
  @tests
end

Class Method Details

.find(inputs, env) ⇒ Object



5
6
7
# File 'lib/test_file_runner.rb', line 5

def self.find(inputs, env)
  new(env, false).find(inputs)
end

.status(env, ignore_selenium = false) ⇒ Object



9
10
11
# File 'lib/test_file_runner.rb', line 9

def self.status(env, ignore_selenium=false)
  new(env, ignore_selenium).status
end

Instance Method Details

#find(inputs) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/test_file_runner.rb', line 21

def find(inputs)
  files = []
  inputs.each {|input| files << repo.find_files(input).map {|f| {:file => f} } }
  files.flatten!
  @tests = TestCollection.new(files)
  if @tests.present?
    test_runner.run_files(tests)
  else
    shell.notify "Could not find matching test file."
  end
end

#statusObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/test_file_runner.rb', line 33

def status
  files = repo.status_files.map {|f| {:file => f} }
  @tests = TestCollection.new(files)

  if tests.include_selenium?
    handle_selenium
  end

  if tests.empty?
    shell.notify 'No tests to run'
    exit
  end

  test_runner.run_files(tests)
end