diff --git a/test/test_erb_processor.rb b/test/test_erb_processor.rb index aa9f9a429..7929c96a8 100644 --- a/test/test_erb_processor.rb +++ b/test/test_erb_processor.rb @@ -3,6 +3,7 @@ require 'sprockets' require 'sprockets/cache' require 'sprockets/erb_processor' +require 'sass' class TestERBProcessor < MiniTest::Test @@ -11,7 +12,7 @@ def uri_path(path) path end - def tset_compile_js_erb_template + def test_compile_js_erb_template environment = Sprockets::Environment.new input = { @@ -92,4 +93,23 @@ def foo output = "var foo = bar;" assert_equal output, template.call(input)[:data] end + + def test_compile_js_erb_template_with_top_level_constant_access + environment = Sprockets::Environment.new + + Sprockets.const_set(:Sass, Class.new) + + input = { + environment: environment, + filename: "foo.js.erb", + content_type: 'application/javascript', + data: "var sass_version = '<%= Sass::VERSION %>';", + metadata: {}, + cache: Sprockets::Cache.new + } + + assert_match /sass_version/, Sprockets::ERBProcessor.call(input)[:data] + ensure + Sprockets.send(:remove_const, :Sass) + end end