Sha256: b2838e4833d7a2e41820adb92cc82760f885dc5e3ea1e8a5affed908fb2ba17c

Contents?: true

Size: 718 Bytes

Versions: 8

Compression:

Stored size: 718 Bytes

Contents

require "rake"

module Jstdutil
  # Knows how to map source files to test files, how to extract test cases
  # and so on.
  #
  class TestFile
    def initialize(file)
      @file = file
    end

    def test_files
      return @test_files if @test_files

      if @file =~ /(_test[^\/]+)|([^\/]+_test)\.js/
        @test_files = [@file]
      else
        name = File.basename(@file).gsub(/(_test)|(test_)|(\.js)/, "")
        @test_files = FileList["**/#{name}_test.js", "**/test_#{name}.js"].uniq
      end
    end

    def test_cases
      return @cases if @cases

      @cases = test_files.collect do |file|
        File.read(file).scan(/estCase\(["']([^"']*)/)
      end

      @cases.flatten!
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jstdutil-0.3.5 lib/jstdutil/test_file.rb
jstdutil-0.3.4 lib/jstdutil/test_file.rb
jstdutil-0.3.3 lib/jstdutil/test_file.rb
jstdutil-0.3.2 lib/jstdutil/test_file.rb
jstdutil-0.3.1 lib/jstdutil/test_file.rb
jstdutil-0.3.0 lib/jstdutil/test_file.rb
jstdutil-0.2.2 lib/jstdutil/test_file.rb
jstdutil-0.2.1 lib/jstdutil/test_file.rb