Module: Guard::PHPUnit::Inspector

Defined in:
lib/guard/phpunit/inspector.rb

Overview

The Guard::PHPUnit inspector verfies that the changed paths are valid for Guard::PHPUnit.

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Class Attribute Details

+ (Object) tests_path

Returns the value of attribute tests_path



10
11
12
# File 'lib/guard/phpunit/inspector.rb', line 10

def tests_path
  @tests_path
end

Class Method Details

+ (Array<String>) clean(paths)

Clean the changed paths and return only valid PHPUnit tests files.

Parameters:

  • paths (Array<String>)

    the changed paths

Returns:

  • (Array<String>)

    the valid tests files



18
19
20
21
22
23
24
# File 'lib/guard/phpunit/inspector.rb', line 18

def clean(paths)
  paths.uniq!
  paths.compact!
  paths = paths.select { |p| test_file?(p) }
  clear_tests_files_list
  paths
end

+ (Object) clear_tests_files_list (private)

Clears the list of PHPUnit tests.

See Also:

  • #clean


48
49
50
# File 'lib/guard/phpunit/inspector.rb', line 48

def clear_tests_files_list
  @tests_files = nil
end

+ (Boolean) test_file?(path) (private)

Checks if the paths is a valid test file.

Parameters:

  • path (String)

    the test path

Returns:

  • (Boolean)

    whether the path a valid test or not



33
34
35
# File 'lib/guard/phpunit/inspector.rb', line 33

def test_file?(path)
  tests_files.include?(path)
end

+ (Object) tests_files (private)

Scans the tests path and keeps a list of all tests paths.



40
41
42
# File 'lib/guard/phpunit/inspector.rb', line 40

def tests_files
  @tests_files ||= Dir.glob( File.join(tests_path, '**', '*Test.php') )
end