#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../test_helper' class ConversionTest < Test::Unit::TestCase def test_basic assert_renders < true foo bar :baz bang :bip bop SASS foo bar { baz: bang; bip: bop; } SCSS end def test_nesting assert_renders < true foo bar :baz= 12 $bang "bip" SASS foo bar { baz= 12 $bang "bip"; } SCSS end def test_multiline_properties assert_scss_to_sass < :scss)).rstrip, "Expected SCSS to transform to Sass") end def assert_scss_to_scss(scss, in_scss = nil, options = nil) if in_scss.is_a?(Hash) options = in_scss in_scss = nil end in_scss ||= scss options ||= {} assert_equal(scss.rstrip, to_scss(in_scss, options.merge(:syntax => :scss)).rstrip, "Expected SCSS to transform to #{scss == in_scss ? 'itself' : 'SCSS'}k") end def assert_sass_to_scss(scss, sass, options = {}) assert_equal(scss.rstrip, to_scss(sass, options).rstrip, "Expected Sass to transform to SCSS") end def assert_renders(sass, scss, options = {}) assert_sass_to_sass(sass, options) assert_scss_to_sass(sass, scss, options) assert_scss_to_scss(scss, options) assert_sass_to_scss(scss, sass, options) end def to_sass(scss, options = {}) Sass::Engine.new(scss, options).to_tree.to_sass(options) end def to_scss(sass, options = {}) Sass::Engine.new(sass, options).to_tree.to_scss(options) end end