Class: GARunner
- Inherits:
-
Object
- Object
- GARunner
- Defined in:
- lib/ga_runner.rb
Overview
Instance Method Summary collapse
-
#codeFilename ⇒ String
The code file corresponding to @filename, stripping the suffix if @filename is a test file.
-
#initialize(configuration, filename) ⇒ GARunner
constructor
Creates a new instance given a GAConfiguration object and a filename to run tests.
-
#isTest ⇒ Object
True if the filename is a tests file.
-
#test ⇒ Object
Tries to run unit tests for the filename setup during initialization.
-
#testIfAvailable(filename) ⇒ Object
Runs unit tests for the given filename, if a tests file exists.
Constructor Details
#initialize(configuration, filename) ⇒ GARunner
filename can also be a tests file
Creates a new instance given a GAConfiguration object and a filename to run tests
13 14 15 16 17 |
# File 'lib/ga_runner.rb', line 13 def initialize(configuration, filename) @configuration=configuration @filename=filename @runner=XcodebuildRunner.new(configuration) end |
Instance Method Details
#codeFilename ⇒ String
Returns the code file corresponding to @filename, stripping the suffix if @filename is a test file.
50 51 52 53 54 55 56 57 58 |
# File 'lib/ga_runner.rb', line 50 def codeFilename() suffix = @configuration.suffix stripped = @filename if isTest() stripped = @filename.slice(/(?<file>.*)#{suffix}$/, "file") end return stripped end |
#isTest ⇒ Object
Returns true if the filename is a tests file.
45 46 47 |
# File 'lib/ga_runner.rb', line 45 def isTest() return @filename.end_with? @configuration.suffix end |
#test ⇒ Object
Tries to run unit tests for the filename setup during initialization
(see #testIfAvailable)
39 40 41 42 |
# File 'lib/ga_runner.rb', line 39 def test() @runner.prepareForFile(@filename) testIfAvailable(codeFilename()) end |
#testIfAvailable(filename) ⇒ Object
filename must be a code file, not a tests file. If you’re not sure whether the file is a tests file or not, use #test instead
if a corresponding tests file cannot be found, outputs a warning line
Runs unit tests for the given filename, if a tests file exists
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ga_runner.rb', line 24 def testIfAvailable(filename) suffix = @configuration.suffix fileExists = system("find . | grep '" + filename + suffix + "' > /dev/null") if !fileExists GALogger.log(filename + " doesn't seem to have associated tests. You should think about creating some.", :Warning) return end @runner.test(filename) end |