Sha256: 728739af4a95d5b69f9866937af4848135ae953345fc8a8e37c816d1ec1e0bf2

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

# -*- encoding: utf-8 -*-

require 'webgen/test_helper'
require 'webgen/content_processor/sass'
require 'webgen/path'

class TestSass < MiniTest::Unit::TestCase

  include Webgen::TestHelper

  def test_static_call
    setup_context
    @website.ext.sass_load_paths = []
    @website.config['content_processor.sass.options'] = {}
    cp = Webgen::ContentProcessor::Sass

    @context.content = "#main\n  :background-color #000"
    result = "#main {\n  background-color: black; }\n"
    assert_equal(result, cp.call(@context).content)

    @context.content = "#cont\n = 5"
    assert_error_on_line(Webgen::RenderError, 2) { cp.call(@context) }

    # test @import-ing of sass files
    content = "#main\n  background-image: relocatable('../dir2/file.test')"
    result = "#main {\n  background-image: url(\"../../dir2/file.test\"); }\n"
    root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
    dir = Webgen::Node.new(root, 'dir/', '/dir/')
    partial = Webgen::Node.new(dir, '_partial.sass', '/dir/_partial.sass')
    partial.node_info[:path] = Webgen::Path.new('test') { StringIO.new(content) }
    dirdir = Webgen::Node.new(dir, 'dir/', '/dir/dir/')
    sass = Webgen::Node.new(dirdir, 'file.sass', '/dir/dir/file.sass')
    dir2 = Webgen::Node.new(root, 'dir2/', '/dir2/')
    file = Webgen::Node.new(dir2, 'file.test', '/dir2/file.test')

    @context[:chain] = [sass]
    @context.content = "@import 'unknown'"
    assert_error_on_line(Webgen::RenderError, 1) { cp.call(@context) }

    @context.content = "@import 'dir/partial' \n@import 'dir/_partial' \n@import 'dir/partial.sass'"
    assert_equal("#{result}\n#{result}\n#{result}", cp.call(@context).content)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webgen-1.0.0.beta1 test/webgen/content_processor/test_sass.rb