Class: EnvironmentTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- EnvironmentTest
- Defined in:
- lib/sprockets/test/test_environment.rb
Instance Method Summary collapse
- #test_constants_should_return_a_hash_of_all_constants_defined_in_the_load_path ⇒ Object
- #test_find_should_return_nil_when_no_matching_source_file_is_found ⇒ Object
- #test_find_should_return_the_first_matching_pathname_in_the_load_path ⇒ Object
- #test_load_path_locations_become_pathnames_for_absolute_locations_from_the_root ⇒ Object
- #test_pathname_from_for_location_with_leading_slash_should_return_a_pathname_with_the_location_unchanged ⇒ Object
- #test_pathname_from_for_relative_location_should_return_a_pathname_for_the_expanded_absolute_location_from_root ⇒ Object
- #test_register_load_location_should_remove_already_existing_locations_before_unshifting ⇒ Object
- #test_register_load_location_should_unshift_the_location_onto_the_load_path ⇒ Object
Instance Method Details
#test_constants_should_return_a_hash_of_all_constants_defined_in_the_load_path ⇒ Object
54 55 56 57 58 |
# File 'lib/sprockets/test/test_environment.rb', line 54 def test_constants_should_return_a_hash_of_all_constants_defined_in_the_load_path constants = environment_for_fixtures.constants assert_kind_of Hash, constants assert_equal %w(HELLO ONE TWO VERSION), constants.keys.sort end |
#test_find_should_return_nil_when_no_matching_source_file_is_found ⇒ Object
49 50 51 52 |
# File 'lib/sprockets/test/test_environment.rb', line 49 def test_find_should_return_nil_when_no_matching_source_file_is_found environment = environment_for_fixtures assert_nil environment.find("nonexistent.js") end |
#test_find_should_return_the_first_matching_pathname_in_the_load_path ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sprockets/test/test_environment.rb', line 38 def test_find_should_return_the_first_matching_pathname_in_the_load_path environment = environment_for_fixtures first_pathname = environment.find("foo.js") assert_absolute_location_ends_with "src/foo.js", first_pathname environment.register_load_location(File.join(FIXTURES_PATH, "src", "foo")) second_pathname = environment.find("foo.js") assert_not_equal first_pathname, second_pathname assert_absolute_location_ends_with "foo/foo.js", second_pathname end |
#test_load_path_locations_become_pathnames_for_absolute_locations_from_the_root ⇒ Object
4 5 6 7 |
# File 'lib/sprockets/test/test_environment.rb', line 4 def test_load_path_locations_become_pathnames_for_absolute_locations_from_the_root environment = Sprockets::Environment.new("/root", ["/a", "b"]) assert_load_path_equals ["/a", "/root/b", "/root"], environment end |
#test_pathname_from_for_location_with_leading_slash_should_return_a_pathname_with_the_location_unchanged ⇒ Object
9 10 11 12 |
# File 'lib/sprockets/test/test_environment.rb', line 9 def test_pathname_from_for_location_with_leading_slash_should_return_a_pathname_with_the_location_unchanged environment = Sprockets::Environment.new("/root") assert_absolute_location "/a", environment.pathname_from("/a") end |
#test_pathname_from_for_relative_location_should_return_a_pathname_for_the_expanded_absolute_location_from_root ⇒ Object
14 15 16 17 18 19 |
# File 'lib/sprockets/test/test_environment.rb', line 14 def environment = Sprockets::Environment.new("/root") assert_absolute_location "/root/a", environment.pathname_from("a") assert_absolute_location "/root/a", environment.pathname_from("./a") assert_absolute_location "/a", environment.pathname_from("../a") end |
#test_register_load_location_should_remove_already_existing_locations_before_unshifting ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/sprockets/test/test_environment.rb', line 29 def test_register_load_location_should_remove_already_existing_locations_before_unshifting environment = Sprockets::Environment.new("/root") environment.register_load_location("a") environment.register_load_location("b") assert_load_path_equals ["/root/b", "/root/a", "/root"], environment environment.register_load_location("a") assert_load_path_equals ["/root/a", "/root/b", "/root"], environment end |
#test_register_load_location_should_unshift_the_location_onto_the_load_path ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/sprockets/test/test_environment.rb', line 21 def test_register_load_location_should_unshift_the_location_onto_the_load_path environment = Sprockets::Environment.new("/root") environment.register_load_location("a") assert_load_path_equals ["/root/a", "/root"], environment environment.register_load_location("b") assert_load_path_equals ["/root/b", "/root/a", "/root"], environment end |