File: node_mincer_test.rb

package info (click to toggle)
ruby-bootstrap-sass 3.4.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,368 kB
  • sloc: javascript: 3,526; ruby: 1,211; sh: 57; makefile: 9
file content (35 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'test_helper'
require 'json'

class NodeMincerTest < Minitest::Test
  DUMMY_PATH = 'test/dummy_node_mincer'

  def test_font_helper_without_suffix
    assert_match %r(url\(['"]?/assets/.*eot['"]?\)), @css
  end

  def test_font_helper_with_suffix_sharp
    assert_match %r(url\(['"]?/assets/.*svg#.+['"]?\)), @css
  end

  def test_font_helper_with_suffix_question
    assert_match %r(url\(['"]?/assets/.*eot\?.*['"]?\)), @css
  end

  def test_image_helper
    assert_match %r(url\(['"]?/assets/apple-touch-icon-144-precomposed.*png['"]?\)), @css
  end

  def setup
    tmp_dir = File.join GEM_PATH, 'tmp/node-mincer'
    success = Dir.chdir DUMMY_PATH do
      silence_stdout_if !ENV['VERBOSE'] do
        system 'node', 'manifest.js', tmp_dir
      end
    end
    assert success, 'Node.js Mincer compilation failed'
    manifest = JSON.parse(File.read("#{tmp_dir}/manifest.json"))
    css_name = manifest['assets']['application.css']
    @css = File.read("#{tmp_dir}/#{css_name}")
  end
end