1
0
Fork 0
mirror of https://github.com/twbs/bootstrap-sass.git synced 2022-11-09 12:27:02 -05:00
twbs--bootstrap-sass/test/sprockets_rails_test.rb

32 lines
942 B
Ruby
Raw Normal View History

2018-08-21 22:34:39 +01:00
# frozen_string_literal: true
require 'test_helper'
require 'fileutils'
require 'find'
require 'shellwords'
2014-09-02 23:48:44 +02:00
class SprocketsRailsTest < Minitest::Test
def test_sprockets_digest_asset_refs
2018-08-21 22:34:39 +01:00
root = 'test/dummy_rails'
2014-09-02 23:48:44 +02:00
compiled = Dir.chdir root do
silence_stderr_if !ENV['VERBOSE'] do
2018-08-21 22:34:39 +01:00
Bundler.with_original_env do
system({ 'BUNDLE_GEMFILE' => File.join(GEM_PATH, 'Gemfile'),
'RAILS_ENV' => 'production' },
2018-08-21 22:49:42 +01:00
'bundle && bundle exec rake assets:precompile')
2018-08-21 22:34:39 +01:00
end
2014-09-02 23:48:44 +02:00
end
end
assert compiled, 'Could not precompile assets'
Dir.glob(File.join(root, 'public', 'assets', 'app*.{css,js}')) do |path|
2018-08-21 22:34:39 +01:00
File.read(path)
.scan(/url\("?[^"]+\.(?:jpg|png|eot|woff2?|ttf|svg)[^"]*"?\)/) do |m|
assert_match(/-[0-9a-f]{12,}\./, m)
end
end
ensure
2018-08-21 22:34:39 +01:00
FileUtils.rm_rf %W[#{root}/public/assets/ #{root}/tmp/cache/], secure: true
end
end