Version 1
[yaffs-website] / vendor / twbs / bootstrap-sass / test / node_mincer_test.rb
1 require 'test_helper'
2 require 'json'
3
4 class NodeMincerTest < Minitest::Test
5   DUMMY_PATH = 'test/dummy_node_mincer'
6
7   def test_font_helper_without_suffix
8     assert_match %r(url\(['"]?/assets/.*eot['"]?\)), @css
9   end
10
11   def test_font_helper_with_suffix_sharp
12     assert_match %r(url\(['"]?/assets/.*svg#.+['"]?\)), @css
13   end
14
15   def test_font_helper_with_suffix_question
16     assert_match %r(url\(['"]?/assets/.*eot\?.*['"]?\)), @css
17   end
18
19   def test_image_helper
20     assert_match %r(url\(['"]?/assets/apple-touch-icon-144-precomposed.*png['"]?\)), @css
21   end
22
23   def setup
24     tmp_dir = File.join GEM_PATH, 'tmp/node-mincer'
25     success = Dir.chdir DUMMY_PATH do
26       silence_stdout_if !ENV['VERBOSE'] do
27         system 'node', 'manifest.js', tmp_dir
28       end
29     end
30     assert success, 'Node.js Mincer compilation failed'
31     manifest = JSON.parse(File.read("#{tmp_dir}/manifest.json"))
32     css_name = manifest['assets']['application.css']
33     @css = File.read("#{tmp_dir}/#{css_name}")
34   end
35 end