assets_test.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. require 'test_helper'
  2. require 'coffee-rails'
  3. class AssetsTest < ActiveSupport::TestCase
  4. def setup
  5. require "rails"
  6. require "action_controller/railtie"
  7. require "sprockets/railtie"
  8. @app = Class.new(Rails::Application)
  9. @app.config.active_support.deprecation = :stderr
  10. @app.config.assets.enabled = true
  11. @app.config.assets.cache_store = [ :file_store, "#{tmp_path}/cache" ]
  12. @app.paths["log"] = "#{tmp_path}/log/test.log"
  13. @app.initialize!
  14. end
  15. def teardown
  16. FileUtils.rm_rf "#{tmp_path}/cache"
  17. FileUtils.rm_rf "#{tmp_path}/log"
  18. File.delete "#{tmp_path}/coffee-script.js"
  19. end
  20. test "coffee-script.js is included in Sprockets environment" do
  21. @app.assets["coffee-script"].write_to("#{tmp_path}/coffee-script.js")
  22. assert_match "/lib/assets/javascripts/coffee-script.js.erb", @app.assets["coffee-script"].pathname.to_s
  23. assert_match "this.CoffeeScript", File.open("#{tmp_path}/coffee-script.js").read
  24. end
  25. def tmp_path
  26. "#{File.dirname(__FILE__)}/tmp"
  27. end
  28. end