gems.sass-3.2.9.test.sass.scss.test_helper.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!
require File.dirname(__FILE__) + '/../../test_helper'
require 'sass/engine'
module ScssTestHelper
def assert_parses(scss)
assert_equal scss.rstrip, render(scss).rstrip
end
def assert_not_parses(expected, scss)
raise "Template must include where an error is expected" unless scss.include?("")
after, was = scss.split("")
line = after.count("\n") + 1
after.gsub!(/\s*\n\s*$/, '')
after.gsub!(/.*\n/, '')
after = "..." + after[-15..-1] if after.size > 18
was.gsub!(/^\s*\n\s*/, '')
was.gsub!(/\n.*/, '')
was = was[0...15] + "..." if was.size > 18
to_render = scss.sub("", "")
render(to_render)
assert(false, "Expected syntax error for:\n#{to_render}\n")
rescue Sass::SyntaxError => err
assert_equal("Invalid CSS after \"#{after}\": expected #{expected}, was \"#{was}\"",
err.message)
assert_equal line, err.sass_line
end
def render(scss, options = {})
options[:syntax] ||= :scss
munge_filename options
Sass::Engine.new(scss, options).render
end
end