Class: Jstdutil::TestFile
- Inherits:
-
Object
- Object
- Jstdutil::TestFile
- Defined in:
- lib/jstdutil/test_file.rb
Overview
Knows how to map source files to test files, how to extract test cases and so on.
Instance Method Summary collapse
-
#initialize(file) ⇒ TestFile
constructor
A new instance of TestFile.
- #test_cases ⇒ Object
- #test_files ⇒ Object
Constructor Details
#initialize(file) ⇒ TestFile
Returns a new instance of TestFile.
8 9 10 |
# File 'lib/jstdutil/test_file.rb', line 8 def initialize(file) @file = file end |
Instance Method Details
#test_cases ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/jstdutil/test_file.rb', line 27 def test_cases return @cases if @cases @cases = test_files.collect do |file| File.read(file).scan(/estCase\(["']([^"']*)/) end @cases.flatten! end |
#test_files ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jstdutil/test_file.rb', line 12 def test_files return @test_files if @test_files if @file =~ /([-_]test[^\/]+)|([^\/]+[-_]test)|(Test)\.js/ @test_files = [@file] else name = File.basename(@file).gsub(/([-_]test)|(test[-_])|(\.js)/, "") @test_files = FileList["**/#{name}_test.js", "**/test_#{name}.js", "**/#{name}-test.js", "**/test-#{name}.js", "**/#{camelize(name)}Test.js"].uniq end end |