UNPKG

831 BPlain TextView Raw
1require 'test_helper'
2require 'fileutils'
3require 'find'
4require 'shellwords'
5
6class SprocketsRailsTest < Minitest::Test
7
8 def test_sprockets_digest_asset_refs
9 root = 'test/dummy_rails'
10 command = "bundle exec rake assets:precompile GEMFILE=#{GEM_PATH}/Gemfile RAILS_ENV=production"
11 compiled = Dir.chdir root do
12 silence_stderr_if !ENV['VERBOSE'] do
13 system(command)
14 end
15 end
16 assert compiled, 'Could not precompile assets'
17 Dir.glob(File.join(root, 'public', 'assets', 'app*.{css,js}')) do |path|
18 File.open(path, 'r') do |f|
19 f.read.scan /url\("?[^"]+\.(?:jpg|png|eot|woff|ttf|svg)[^"]*"?\)/ do |m|
20 assert_match /-[0-9a-f]{12,}\./, m
21 end
22 end
23 end
24 ensure
25 FileUtils.rm_rf %W(#{root}/public/assets/ #{root}/tmp/cache/), secure: true
26 end
27end
28
\No newline at end of file