Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Fix the tests under Ruby 1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Feb 16, 2009
1 parent 594aaac commit 7fc1208
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions test/test_secretary.rb
Expand Up @@ -3,15 +3,15 @@
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 }
end

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 }
Expand All @@ -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 }
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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, "**", "*")]
Expand Down
3 changes: 2 additions & 1 deletion test/test_source_file.rb
@@ -1,13 +1,14 @@
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 = 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
Expand Down

0 comments on commit 7fc1208

Please sign in to comment.