Sha256: 8a13c118fb8904046c78eca131f39025d801e037d3a1f9e8863e9db94401c0e2

Contents?: true

Size: 1.34 KB

Versions: 49

Compression:

Stored size: 1.34 KB

Contents

require "test_helper"
require "enumerator"
Enumerator = Enumerable::Enumerator unless defined?(Enumerator) # for 1.9.1 compatibility

class SourceFileTest < Test::Unit::TestCase
  def setup
    @environment = environment_for_fixtures
  end
  
  def test_each_source_line
    source_file_lines = Enumerator.new(source_file("src/foo/bar.js"), :each_source_line).to_a
    assert_equal content_of_fixture("src/foo/bar.js"), source_file_lines.map { |line| line.line }.join
    assert_equal 4, source_file_lines.length
  end
  
  def test_find_should_return_pathname_for_file_relative_to_the_current_pathname
    assert_absolute_location_ends_with "test/fixtures/src/foo/bar.js", source_file("src/foo/foo.js").find("bar.js")
  end
  
  def test_find_should_return_nil_for_nonexistent_file
    assert_nil source_file("src/foo/foo.js").find("nonexistent.js")
  end
  
  def test_equality_of_source_files
    assert_equal source_file("src/foo/foo.js"), source_file("src/foo/foo.js")
    assert_equal source_file("src/foo/foo.js"), source_file("src/foo/../foo/foo.js")
    assert_not_equal source_file("src/foo/foo.js"), source_file("src/foo.js")
    assert_not_equal source_file("src/foo/foo.js"), source_file("src/foo/bar.js")
  end
  
  def test_mtime_should_return_now_if_file_does_not_exist
    assert source_file("src/foo/nonexistent.js").mtime.instance_of?(Time)
  end
end

Version data entries

49 entries across 48 versions & 5 rubygems

Version Path
amiel-sprockets-1.0.5 test/test_source_file.rb
architecture-js-0.6.3 lib/sprockets/test/test_source_file.rb
architecture-js-0.6.2 lib/sprockets/test/test_source_file.rb
architecture-js-0.6.1 lib/sprockets/test/test_source_file.rb
architecture-js-0.6.0 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.8 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.7 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.6 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.5 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.4 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.3 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.2 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.1 lib/sprockets/test/test_source_file.rb
architecture-js-0.5.0 lib/sprockets/test/test_source_file.rb
architecture-js-0.4.0 lib/sprockets/test/test_source_file.rb
architecture-js-0.3.8 lib/sprockets/test/test_source_file.rb
architecture-js-0.3.7 lib/sprockets/test/test_source_file.rb
architecture-js-0.3.6 lib/sprockets/test/test_source_file.rb
architecture-js-0.3.5 lib/sprockets/test/test_source_file.rb
architecture-js-0.3.4 lib/sprockets/test/test_source_file.rb