Class: PathnameTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/sprockets/test/test_pathname.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



4
5
6
# File 'lib/sprockets/test/test_pathname.rb', line 4

def setup
  @environment = environment_for_fixtures
end

#test_absolute_location_is_automatically_expandedObject



8
9
10
11
12
13
# File 'lib/sprockets/test/test_pathname.rb', line 8

def test_absolute_location_is_automatically_expanded
  expanded_location = File.expand_path(File.join(FIXTURES_PATH, "foo"))
  assert_absolute_location expanded_location, pathname("foo")
  assert_absolute_location expanded_location, pathname("./foo")
  assert_absolute_location expanded_location, pathname("./foo/../foo")
end

#test_equality_of_pathnamesObject



34
35
36
37
38
# File 'lib/sprockets/test/test_pathname.rb', line 34

def test_equality_of_pathnames
  assert_equal pathname("src/foo.js"), pathname("src/foo.js")
  assert_equal pathname("src/foo.js"), pathname("src/foo/../foo.js")
  assert_not_equal pathname("src/foo.js"), pathname("src/foo/foo.js")
end

#test_find_should_return_a_pathname_for_the_location_relative_to_the_absolute_location_of_the_pathnameObject



15
16
17
# File 'lib/sprockets/test/test_pathname.rb', line 15

def test_find_should_return_a_pathname_for_the_location_relative_to_the_absolute_location_of_the_pathname
  assert_absolute_location_ends_with "src/foo/bar.js", pathname("src/foo").find("bar.js")
end

#test_find_should_return_nil_when_the_location_relative_to_the_absolute_location_of_the_pathname_is_not_a_file_or_does_not_existObject



19
20
21
# File 'lib/sprockets/test/test_pathname.rb', line 19

def test_find_should_return_nil_when_the_location_relative_to_the_absolute_location_of_the_pathname_is_not_a_file_or_does_not_exist
  assert_nil pathname("src/foo").find("nonexistent.js")
end

#test_parent_pathname_should_return_a_pathname_for_the_parent_directoryObject



23
24
25
26
# File 'lib/sprockets/test/test_pathname.rb', line 23

def test_parent_pathname_should_return_a_pathname_for_the_parent_directory
  assert_absolute_location_ends_with "src", pathname("src/foo").parent_pathname
  assert_absolute_location_ends_with "foo", pathname("src/foo/foo.js").parent_pathname
end

#test_source_file_should_return_a_source_file_for_the_pathnameObject



28
29
30
31
32
# File 'lib/sprockets/test/test_pathname.rb', line 28

def test_source_file_should_return_a_source_file_for_the_pathname
  source_file = pathname("src/foo.js").source_file
  assert_kind_of Sprockets::SourceFile, source_file
  assert_equal pathname("src/foo.js"), source_file.pathname
end

#test_to_s_should_return_absolute_locationObject



40
41
42
# File 'lib/sprockets/test/test_pathname.rb', line 40

def test_to_s_should_return_absolute_location
  assert_equal pathname("src/foo.js").to_s, pathname("src/foo.js").absolute_location
end