Sha256: 3442d2b659f4574e5f4c254eb80afaea270c3ff145e63b2efee434af439d7182

Contents?: true

Size: 1.96 KB

Versions: 17

Compression:

Stored size: 1.96 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")

module JsTestCore
  module Resources
    describe CoreFile do
      describe "Files" do
        describe "GET /core/JsTestCore.js" do
          it "renders the JsTestCore.js file, which lives in the core framework directory" do
            absolute_path = "#{core_path}/JsTestCore.js"

            response = get(CoreFile.path("JsTestCore.js"))
            response.should be_http(
              200,
              {
                "Content-Type" => "text/javascript",
                "Last-Modified" => ::File.mtime(absolute_path).rfc822
              },
              ::File.read(absolute_path)
            )
          end
        end
      end

      describe "Directories" do
        macro "returns a page with the files in the root core directory" do |relative_path|
          it "returns a page with the files in the root core directory" do
            response = get(CoreFile.path(relative_path))
            response.should be_http(
              200,
              {},
              ""
            )
            doc = Nokogiri::HTML(response.body)
            links = doc.search("a").map {|script| script["href"]}
            links.should include("/core/JsTestCore.js")
            links.should include("/core/JsTestCore.css")
            links.should include("/core/subdir")
          end
        end
        describe "GET /core" do
          send("returns a page with the files in the root core directory", "")
        end
        describe "GET /core/" do
          send("returns a page with the files in the root core directory", "/")
        end

        describe "GET /core/subdir" do
          it "returns a page with the files in the directory" do
            response = get(CoreFile.path("subdir"))
            response.should be_http(
              200,
              {},
              %r(<a href="/core/subdir/SubDirFile.js">SubDirFile.js</a>)
            )
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
pivotal-screw-unit-0.5.0 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-0.5.1 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-0.5.2 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-0.5.3 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.10 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.11 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.12 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.3 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.4 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.5 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.6 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.7 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.8 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
pivotal-screw-unit-server-0.5.9 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
screw-unit-0.5.1 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
screw-unit-0.5.2 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb
screw-unit-server-0.5.3 vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb