gems.sass-3.2.9.test.sass.scss.scss_test.rb Maven / Gradle / Ivy
Go to download
Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector
inheritance, and more. It's translated to well-formatted, standard CSS using the command line tool or a
web-framework plugin.
This is a repackaged GEM in a JAR format of the sass-lang.gem package. The sass-gems package version
follows the sass-lang.gem versions located http://rubyforge.org/frs/?group_id=9702. Simply change
the version of this package to download and repackage the same GEM version.
The newest version!
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/test_helper'
class ScssTest < Test::Unit::TestCase
include ScssTestHelper
## One-Line Comments
def test_one_line_comments
assert_equal < e
assert_equal < e
assert_equal "Undefined mixin 'bar'.", e.message
assert_equal 3, e.sass_line
end
def test_rules_beneath_properties
render < e
assert_equal 'Illegal nesting: Only properties may be nested beneath properties.', e.message
assert_equal 3, e.sass_line
end
def test_uses_property_exception_with_star_hack
render < e
assert_equal 'Invalid CSS after " *bar:baz ": expected ";", was "[fail]; }"', e.message
assert_equal 2, e.sass_line
end
def test_uses_property_exception_with_colon_hack
render < e
assert_equal 'Invalid CSS after " :bar:baz ": expected ";", was "[fail]; }"', e.message
assert_equal 2, e.sass_line
end
def test_uses_rule_exception_with_dot_hack
render <; }
SCSS
assert(false, "Expected syntax error")
rescue Sass::SyntaxError => e
assert_equal 'Invalid CSS after " .bar:baz ": expected "{", was "; }"', e.message
assert_equal 2, e.sass_line
end
def test_uses_property_exception_with_space_after_name
render < e
assert_equal 'Invalid CSS after " bar: baz ": expected ";", was "[fail]; }"', e.message
assert_equal 2, e.sass_line
end
def test_uses_property_exception_with_non_identifier_after_name
render < e
assert_equal 'Invalid CSS after " bar:1px ": expected ";", was "[fail]; }"', e.message
assert_equal 2, e.sass_line
end
def test_uses_property_exception_when_followed_by_open_bracket
render < e
assert_equal 'Invalid CSS after " bar:{baz: ": expected expression (e.g. 1px, bold), was ".fail} }"', e.message
assert_equal 2, e.sass_line
end
def test_script_error
render < e
assert_equal 'Invalid CSS after " bar: "baz" * ": expected expression (e.g. 1px, bold), was "* }"', e.message
assert_equal 2, e.sass_line
end
def test_multiline_script_syntax_error
render < e
assert_equal 'Invalid CSS after " "baz" * ": expected expression (e.g. 1px, bold), was "* }"', e.message
assert_equal 3, e.sass_line
end
def test_multiline_script_runtime_error
render < e
assert_equal "Undefined variable: \"$bang\".", e.message
assert_equal 4, e.sass_line
end
def test_post_multiline_script_runtime_error
render < e
assert_equal "Undefined variable: \"$bop\".", e.message
assert_equal 5, e.sass_line
end
def test_multiline_property_runtime_error
render < e
assert_equal "Undefined variable: \"$bang\".", e.message
assert_equal 4, e.sass_line
end
def test_post_resolution_selector_error
render "\n\nfoo \#{\") bar\"} {a: b}"
assert(false, "Expected syntax error")
rescue Sass::SyntaxError => e
assert_equal 'Invalid CSS after "foo ": expected selector, was ") bar"', e.message
assert_equal 3, e.sass_line
end
def test_parent_in_mid_selector_error
assert_raise_message(Sass::SyntaxError, < :compressed)
z a,z b{display:block}
CSS
a
, b {
z & {
display: block;
}
}
SCSS
end
def test_if_error_line
assert_raise_line(2) {render(< :compressed)
foo{color:#000}
CSS
foo {color: darken(black, 10%)}
SCSS
end
# ref: https://github.com/nex3/sass/issues/104
def test_no_buffer_overflow
template = render <