discourse/spec/components/stylesheet/compiler_spec.rb
2017-07-28 10:20:09 +09:00

30 lines
882 B
Ruby

require 'rails_helper'
require 'stylesheet/compiler'
describe Stylesheet::Compiler do
describe 'compilation' do
Dir["#{Rails.root.join("app/assets/stylesheets")}/*.scss"].each do |path|
path = File.basename(path, '.scss')
it "can compile '#{path}' css" do
css, _map = Stylesheet::Compiler.compile_asset(path)
expect(css.length).to be > 1000
end
end
end
it "supports asset-url" do
css, _map = Stylesheet::Compiler.compile(".body{background-image: asset-url('foo.png');}", "test.scss")
expect(css).to include("url('/foo.png')")
expect(css).not_to include('asset-url')
end
it "supports image-url" do
css, _map = Stylesheet::Compiler.compile(".body{background-image: image-url('foo.png');}", "test.scss")
expect(css).to include("url('/images/foo.png')")
expect(css).not_to include('image-url')
end
end