From 7fc1208e0eb1d31d5ddd579abb90fcdfea0156eb Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Mon, 16 Feb 2009 01:50:39 -0600 Subject: [PATCH] Fix the tests under Ruby 1.9.1 --- test/test_secretary.rb | 14 +++++++------- test/test_source_file.rb | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/test_secretary.rb b/test/test_secretary.rb index 25ecd74bd..a2e332502 100644 --- a/test/test_secretary.rb +++ b/test/test_secretary.rb @@ -3,7 +3,7 @@ class SecretaryTest < Test::Unit::TestCase def test_load_locations_are_not_expanded_when_expand_paths_is_false secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) - secretary.add_load_locations("src/**/", :expand_paths => false) + secretary.add_load_location("src/**/", :expand_paths => false) assert_equal [File.join(FIXTURES_PATH, "src/**"), FIXTURES_PATH], secretary.environment.load_path.map { |pathname| pathname.absolute_location } @@ -11,7 +11,7 @@ def test_load_locations_are_not_expanded_when_expand_paths_is_false def test_load_locations_are_expanded_when_expand_paths_is_true secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) - secretary.add_load_locations("src/**/", :expand_paths => true) + secretary.add_load_location("src/**/", :expand_paths => true) assert_equal [File.join(FIXTURES_PATH, "src", "foo"), File.join(FIXTURES_PATH, "src"), FIXTURES_PATH], secretary.environment.load_path.map { |pathname| pathname.absolute_location } @@ -20,13 +20,13 @@ def test_load_locations_are_expanded_when_expand_paths_is_true def test_source_files_are_not_expanded_when_expand_paths_is_false secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) assert_raises(Sprockets::LoadError) do - secretary.add_source_files("src/f*.js", :expand_paths => false) + secretary.add_source_file("src/f*.js", :expand_paths => false) end end def test_source_files_are_expanded_when_expand_paths_is_true secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) - secretary.add_source_files("src/f*.js", :expand_paths => true) + secretary.add_source_file("src/f*.js", :expand_paths => true) assert_equal [File.join(FIXTURES_PATH, "src", "foo.js")], secretary.preprocessor.source_files.map { |source_file| source_file.pathname.absolute_location } @@ -35,7 +35,7 @@ def test_source_files_are_expanded_when_expand_paths_is_true def test_install_assets_into_empty_directory with_temporary_directory do |temp| secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH, :asset_root => temp) - secretary.add_source_files("src/script_with_assets.js") + secretary.add_source_file("src/script_with_assets.js") assert_equal [], Dir[File.join(temp, "**", "*")] secretary.install_assets @@ -50,7 +50,7 @@ def test_install_assets_into_nonexistent_directory with_temporary_directory do |temp| temp = File.join(temp, "assets") secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH, :asset_root => temp) - secretary.add_source_files("src/script_with_assets.js") + secretary.add_source_file("src/script_with_assets.js") assert_equal [], Dir[File.join(temp, "**", "*")] secretary.install_assets @@ -64,7 +64,7 @@ def test_install_assets_into_nonexistent_directory def test_install_assets_into_subdirectories_that_already_exist with_temporary_directory do |temp| secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH, :asset_root => temp) - secretary.add_source_files("src/script_with_assets.js") + secretary.add_source_file("src/script_with_assets.js") FileUtils.mkdir_p(File.join(temp, "images", "script_with_assets")) assert_equal paths_relative_to(temp, "images", "images/script_with_assets"), Dir[File.join(temp, "**", "*")] diff --git a/test/test_source_file.rb b/test/test_source_file.rb index c69f309b6..df5c0dd96 100644 --- a/test/test_source_file.rb +++ b/test/test_source_file.rb @@ -1,5 +1,6 @@ require "test_helper" require "enumerator" +Enumerator = Enumerable::Enumerator unless defined?(Enumerator) # for 1.9.1 compatibility class SourceFileTest < Test::Unit::TestCase def setup @@ -7,7 +8,7 @@ def setup end def test_each_source_line - source_file_lines = Enumerable::Enumerator.new(source_file("src/foo/bar.js"), :each_source_line).to_a + 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