Sha256: 97b31e79408c3d9de07236448889651213792f0a04950a8601cba47f1eb5b253

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

module JsTestCore
  module Resources
    module Specs
      class SpecDir < ::JsTestCore::Resources::Dir
        include Spec

        def get
          if ::File.file?(absolute_path)
            super
          else
            get_generated_spec
          end
        end
        
        def spec_files
          glob("/**/*_spec.js")
        end

        route ANY do |env, name|
          if result = (file(name) || subdir(name) || spec_file(name))
            result
          else
            base_path = "#{relative_path}/#{name}"
            raise "No file or directory found at #{base_path} or spec found at #{base_path}.js."
          end
        end

        protected

        def subdir(name)
          absolute_path, relative_path = determine_child_paths(name)
          if ::File.directory?(absolute_path)
            SpecDir.new(env.merge(:absolute_path => absolute_path, :relative_path => relative_path))
          else
            nil
          end
        end

        def spec_file(name)
          absolute_path, relative_path = determine_child_paths("#{name}.js")
          if ::File.exists?(absolute_path) && !::File.directory?(absolute_path)
            SpecFile.new(env.merge(:absolute_path => absolute_path, :relative_path => relative_path))
          else
            nil
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pivotal-screw-unit-0.4.0 vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb
pivotal-screw-unit-0.4.1 vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb
pivotal-screw-unit-0.4.2 vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb
pivotal-screw-unit-0.4.3 vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb