Skip to content

Commit

Permalink
Merge pull request #397 from rails/schneems/test-top-level-consts
Browse files Browse the repository at this point in the history
Failure case for #394
  • Loading branch information
schneems authored Oct 11, 2016
2 parents 55fbb54 + 5478dbf commit 060b5c0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/test_erb_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'sprockets'
require 'sprockets/cache'
require 'sprockets/erb_processor'
require 'sass'

class TestERBProcessor < MiniTest::Test

Expand All @@ -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 = {
Expand Down Expand Up @@ -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

0 comments on commit 060b5c0

Please sign in to comment.