Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGleb Mazovetskiy <glex.spb@gmail.com>2014-01-16 21:23:57 +0400
committerGleb Mazovetskiy <glex.spb@gmail.com>2014-01-16 21:59:51 +0400
commit6c0efeb6ee20ccdab2b17fd4c71c4a4a29ca7c58 (patch)
tree49f3ea7512b087b0d9da4329b284bac8d7655f1b /test
parent738f14a068eff3a97cbd1f09591d6f8267de4c4e (diff)
sprockets-rails test for #500
test for digest presence in asset refs compiled with Rails in production mode
Diffstat (limited to 'test')
-rw-r--r--test/sprockets_rails_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/sprockets_rails_test.rb b/test/sprockets_rails_test.rb
new file mode 100644
index 0000000..bec80a1
--- /dev/null
+++ b/test/sprockets_rails_test.rb
@@ -0,0 +1,21 @@
+require 'test_helper'
+require 'fileutils'
+require 'find'
+require 'shellwords'
+
+class SprocketsRailsTest < ActiveSupport::TestCase
+
+ def test_sprockets_digest_asset_refs
+ system "cd #{Shellwords.escape Rails.root} && bundle exec rake assets:precompile GEMFILE=#{Bootstrap.gem_path}/Gemfile RAILS_ENV=production"
+ Dir.glob(Rails.root.join('public', 'assets', 'app*.*')) do |path|
+ next unless path =~ /\.(css|js)$/
+ File.open(path, 'r') do |f|
+ f.read.scan /url\("?[^"]+\.(?:jpg|png|eot|woff|ttf|svg)[^"]*"?\)/ do |m|
+ assert_match /-[0-9a-f]{12,}\.$/, m
+ end
+ end
+ end
+ ensure
+ system "rm -rf #{Rails.root}/public/assets/ #{Rails.root}/tmp/cache/"
+ end
+end