Sha256: cc6b52ba318705f7d604b95761dcfb7e2ec6c63f8b11fe5fb9819a10a627b98f
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
class JsTestServer::Server::Resources::SpecFile < JsTestServer::Server::Resources::File map "/specs" get "/?" do do_get end get "*" do do_get end protected def do_get if ::File.exists?(absolute_path) if ::File.directory?(absolute_path) spec_files = ::Dir["#{absolute_path}/#{JsTestServer.javascript_test_file_glob}"].map do |file| ["#{relative_path}#{file.gsub(absolute_path, "")}"] end get_generated_spec(absolute_path, spec_files) else super end elsif ::File.exists?("#{absolute_path}.js") get_generated_spec("#{absolute_path}.js", ["#{relative_path}.js"]) else pass end end def get_generated_spec(real_path, spec_files) html = render_spec(spec_files) headers = { 'Content-Type' => "text/html", 'Last-Modified' => ::File.mtime(real_path).rfc822 } [200, headers, html] end def render_spec(spec_files) JsTestServer.suite_view_class.new(:spec_files => spec_files, :framework_path => framework_path).to_s end def absolute_path @absolute_path ||= ::File.expand_path("#{spec_path}#{relative_path.gsub(%r{^/specs}, "")}") end end
Version data entries
4 entries across 4 versions & 2 rubygems