UNPKG

1.02 kBPlain TextView Raw
1require 'test_helper'
2require 'json'
3
4class 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 command = "node manifest.js #{tmp_dir}"
26 success = Dir.chdir DUMMY_PATH do
27 silence_stdout_if !ENV['VERBOSE'] do
28 system(command)
29 end
30 end
31 assert success, 'Node.js Mincer compilation failed'
32 manifest = JSON.parse(File.read("#{tmp_dir}/manifest.json"))
33 css_name = manifest["assets"]["application.css"]
34 @css = File.read("#{tmp_dir}/#{css_name}")
35 end
36end
37
\No newline at end of file