Sha256: e8bbe19dfa028144416c2e97708ead125f9855f5568696f6e8476a0579a167fb

Contents?: true

Size: 1.04 KB

Versions: 949

Compression:

Stored size: 1.04 KB

Contents

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 <err> where an error is expected" unless scss.include?("<err>")

    after, was = scss.split("<err>")
    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("<err>", "")
    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

Version data entries

949 entries across 658 versions & 22 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/sass-3.2.19/test/sass/scss/test_helper.rb
sass-3.4.22 test/sass/scss/test_helper.rb
sass-3.4.21 test/sass/scss/test_helper.rb
sass-4.0.0.alpha.1 test/sass/scss/test_helper.rb
sass-3.4.20 test/sass/scss/test_helper.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sass-3.4.18/test/sass/scss/test_helper.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sass-3.4.19/test/sass/scss/test_helper.rb
sass-3.4.19 test/sass/scss/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.19/test/sass/scss/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.4/vendor/sass/test/sass/scss/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.15/test/sass/scss/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.17/test/sass/scss/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.5/vendor/sass/test/sass/scss/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.18/test/sass/scss/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.6/vendor/sass/test/sass/scss/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.4/vendor/sass/test/sass/scss/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.5/vendor/sass/test/sass/scss/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/sass-3.1.17/test/sass/scss/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/sass-3.1.18/test/sass/scss/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.6/vendor/sass/test/sass/scss/test_helper.rb