|
| 1 | +require 'minitest/autorun' |
| 2 | +require 'sprockets/railtie' |
| 3 | + |
| 4 | + |
| 5 | +Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) |
| 6 | +class TestAssetUrlProcessor < Minitest::Test |
| 7 | + def setup |
| 8 | + @env = Sprockets::Environment.new |
| 9 | + @env.context_class.class_eval do |
| 10 | + def asset_path(path, options = {}) |
| 11 | + 'image-hexcodegoeshere.png' |
| 12 | + end |
| 13 | + end |
| 14 | + end |
| 15 | + |
| 16 | + def test_basic |
| 17 | + input = { environment: @env, data: 'background: url(image.png);', filename: 'url2.css', metadata: {} } |
| 18 | + output = Sprockets::Rails::AssetUrlProcessor.call(input) |
| 19 | + assert_equal({ data: "background: url(image-hexcodegoeshere.png);" }, output) |
| 20 | + end |
| 21 | + |
| 22 | + def test_spaces |
| 23 | + input = { environment: @env, data: 'background: url( image.png );', filename: 'url2.css', metadata: {} } |
| 24 | + output = Sprockets::Rails::AssetUrlProcessor.call(input) |
| 25 | + assert_equal({ data: "background: url(image-hexcodegoeshere.png);" }, output) |
| 26 | + end |
| 27 | + |
| 28 | + def test_single_quote |
| 29 | + input = { environment: @env, data: "background: url('image.png');", filename: 'url2.css', metadata: {} } |
| 30 | + output = Sprockets::Rails::AssetUrlProcessor.call(input) |
| 31 | + assert_equal({ data: "background: url(image-hexcodegoeshere.png);" }, output) |
| 32 | + end |
| 33 | + |
| 34 | + def test_double_quote |
| 35 | + input = { environment: @env, data: 'background: url("image.png");', filename: 'url2.css', metadata: {} } |
| 36 | + output = Sprockets::Rails::AssetUrlProcessor.call(input) |
| 37 | + assert_equal({ data: "background: url(image-hexcodegoeshere.png);" }, output) |
| 38 | + end |
| 39 | +end |
0 commit comments