1 | require 'test_helper'
|
2 | require 'fileutils'
|
3 | require 'find'
|
4 | require 'shellwords'
|
5 |
|
6 | class 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
|
27 | end
|
28 |
|
\ | No newline at end of file |