<commit_before>require 'sprockets_test'
require 'sprockets/erb_template'

class TestERBTemplate < Sprockets::TestCase
  test "compile js erb template" do
    environment = Sprockets::Environment.new

    input = {
      environment: environment,
      filename: "foo.js.erb",
      content_type: 'application/javascript',
      data: "var data = <%= JSON.generate({foo: true}) %>;",
      cache: Sprockets::Cache.new
    }

    output = "var data = {\"foo\":true};"
    assert_equal output, Sprockets::ERBTemplate.call(input)[:data]
  end
end<commit_msg>Test erb depend_on<commit_after>require 'sprockets_test'
require 'sprockets/erb_template'

class TestERBTemplate < Sprockets::TestCase
  test "compile js erb template" do
    environment = Sprockets::Environment.new

    input = {
      environment: environment,
      filename: "foo.js.erb",
      content_type: 'application/javascript',
      data: "var data = <%= JSON.generate({foo: true}) %>;",
      cache: Sprockets::Cache.new
    }

    output = "var data = {\"foo\":true};"
    assert_equal output, Sprockets::ERBTemplate.call(input)[:data]
  end

  test "compile erb template with depend_on call" do
    environment = Sprockets::Environment.new(FIXTURE_ROOT)
    environment.append_path fixture_path('default')

    path = fixture_path('default/gallery.js')
    input = {
      environment: environment,
      filename: "foo.js.erb",
      content_type: 'application/javascript',
      data: "<%= depend_on('#{path}') %>\nvar data = 'DATA';",
      cache: Sprockets::Cache.new
    }

    output = "var data = 'DATA';"
    result = Sprockets::ERBTemplate.call(input)
    assert_equal output, result[:data]
    assert_equal path, result[:dependency_paths].first
  end
end
{'fraction_non_alphanumeric': 0.13444893248701673, 'fraction_numerical': 0.0, 'mean_word_length': 3.737704918032787, 'pattern_counts': {'":': 2, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7627859', 'n_tokens_mistral': 569, 'n_tokens_neox': 554, 'n_words': 118}