Sha256: 1e420e6e5e0ed195591dd1a3b6e2faf7398d0f11b6f0729234325d2eee666790

Contents?: true

Size: 1.91 KB

Versions: 5

Compression:

Stored size: 1.91 KB

Contents

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

module JsTestCore
  module Resources
    describe Dir do
      attr_reader :dir, :absolute_path, :relative_path

      describe "GET /stylesheets - Top level directory" do
        it "returns a page with a of files in the directory" do
          mock(connection).send_head()
          mock(connection).send_body(%r(<a href="example.css">example.css</a>))

          connection.receive_data("GET /stylesheets HTTP/1.1\r\nHost: _\r\n\r\n")
        end
      end

      describe "GET /javascripts/subdir - Subdirectory" do
        it "returns a page with a of files in the directory" do
          mock(connection).send_head()
          mock(connection).send_body(%r(<a href="bar.js">bar.js</a>))

          connection.receive_data("GET /javascripts/subdir HTTP/1.1\r\nHost: _\r\n\r\n")
        end
      end

      describe "GET /javascripts/i_dont_exist - FileNotFound" do
        it "returns a 404 error" do
          mock(connection).send_head(404)
          mock(connection).send_body("")

          connection.receive_data("GET /javascripts/i_dont_exist HTTP/1.1\r\nHost: _\r\n\r\n")
        end
      end

      describe "#glob" do
        before do
          @absolute_path = spec_root_path
          @relative_path = "/specs"
          @dir = Resources::Dir.new(:connection => connection, :absolute_path => absolute_path, :relative_path => relative_path)
        end

        it "returns an array of matching Files under this directory with the correct relative paths" do
          globbed_files = dir.glob("/**/*_spec.js")
          globbed_files.size.should == 3
          globbed_files.should contain_spec_file_with_correct_paths("/failing_spec.js")
          globbed_files.should contain_spec_file_with_correct_paths("/foo/failing_spec.js")
          globbed_files.should contain_spec_file_with_correct_paths("/foo/passing_spec.js")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
js_spec-0.3.2 vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb
js_spec-0.3.3 vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb
js_test_core-0.2.0 spec/unit/js_test_core/resources/dir_spec.rb
screw-unit-0.3.1 vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb
screw-unit-0.3.3 vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb