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
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
sass-3.6.0 test/sass/scss/test_helper.rb
sass-3.5.7 test/sass/scss/test_helper.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
sass-3.5.6 test/sass/scss/test_helper.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
sass-3.5.5 test/sass/scss/test_helper.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
sass-3.5.4 test/sass/scss/test_helper.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
sass-3.5.3 test/sass/scss/test_helper.rb
sass-3.5.2 test/sass/scss/test_helper.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/scss/test_helper.rb
sass-3.5.1 test/sass/scss/test_helper.rb