Class: SourceFileTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- SourceFileTest
- Defined in:
- lib/sprockets/test/test_source_file.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_each_source_line ⇒ Object
- #test_equality_of_source_files ⇒ Object
- #test_find_should_return_nil_for_nonexistent_file ⇒ Object
- #test_find_should_return_pathname_for_file_relative_to_the_current_pathname ⇒ Object
- #test_mtime_should_return_now_if_file_does_not_exist ⇒ Object
Instance Method Details
#setup ⇒ Object
6 7 8 |
# File 'lib/sprockets/test/test_source_file.rb', line 6 def setup @environment = environment_for_fixtures end |
#test_each_source_line ⇒ Object
10 11 12 13 14 |
# File 'lib/sprockets/test/test_source_file.rb', line 10 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 |
#test_equality_of_source_files ⇒ Object
24 25 26 27 28 29 |
# File 'lib/sprockets/test/test_source_file.rb', line 24 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 |
#test_find_should_return_nil_for_nonexistent_file ⇒ Object
20 21 22 |
# File 'lib/sprockets/test/test_source_file.rb', line 20 def test_find_should_return_nil_for_nonexistent_file assert_nil source_file("src/foo/foo.js").find("nonexistent.js") end |
#test_find_should_return_pathname_for_file_relative_to_the_current_pathname ⇒ Object
16 17 18 |
# File 'lib/sprockets/test/test_source_file.rb', line 16 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 |
#test_mtime_should_return_now_if_file_does_not_exist ⇒ Object
31 32 33 |
# File 'lib/sprockets/test/test_source_file.rb', line 31 def test_mtime_should_return_now_if_file_does_not_exist assert source_file("src/foo/nonexistent.js").mtime.instance_of?(Time) end |