Sha256: 43ce97f807ae2fd4e431e234592971b0046aa99b502cee5abd7d0201dc363c45

Contents?: true

Size: 1.66 KB

Versions: 41

Compression:

Stored size: 1.66 KB

Contents

lib_dir = File.dirname(__FILE__) + '/../lib'

require 'test/unit'
require 'fileutils'
$:.unshift lib_dir unless $:.include?(lib_dir)
require 'sass'

Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)

module Sass::Script::Functions
  module UserFunctions; end
  include UserFunctions

  def option(name)
    Sass::Script::String.new(@options[name.value.to_sym].to_s)
  end
end

class Test::Unit::TestCase
  def munge_filename(opts = {})
    return if opts.has_key?(:filename)
    opts[:filename] = filename_for_test(opts[:syntax] || :sass)
  end

  def filename_for_test(syntax = :sass)
    test_name = caller.
      map {|c| Sass::Util.caller_info(c)[2]}.
      compact.
      map {|c| c.sub(/^(block|rescue) in /, '')}.
      find {|c| c =~ /^test_/}
    "#{test_name}_inline.#{syntax}"
  end

  def clean_up_sassc
    path = File.dirname(__FILE__) + "/../.sass-cache"
    FileUtils.rm_r(path) if File.exist?(path)
  end

  def assert_warning(message)
    the_real_stderr, $stderr = $stderr, StringIO.new
    yield

    if message.is_a?(Regexp)
      assert_match message, $stderr.string.strip
    else
      assert_equal message.strip, $stderr.string.strip
    end
  ensure
    $stderr = the_real_stderr
  end

  def silence_warnings(&block)
    Sass::Util.silence_warnings(&block)
  end

  def assert_raise_message(klass, message)
    yield
  rescue Exception => e
    assert_instance_of(klass, e)
    assert_equal(message, e.message)
  else
    flunk "Expected exception #{klass}, none raised"
  end

  def assert_raise_line(line)
    yield
  rescue Sass::SyntaxError => e
    assert_equal(line, e.sass_line)
  else
    flunk "Expected exception on line #{line}, none raised"
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
haml-3.1.0 vendor/sass/test/test_helper.rb
sass-3.1.0.alpha.221 test/test_helper.rb
sass-3.1.0.alpha.218 test/test_helper.rb
sass-3.1.0.alpha.217 test/test_helper.rb
sass-3.1.0.alpha.216 test/test_helper.rb
sass-3.1.0.alpha.212 test/test_helper.rb
sass-3.1.0.alpha.214 test/test_helper.rb
sass-3.1.0.alpha.210 test/test_helper.rb
haml-3.1.0.alpha.147 vendor/sass/test/test_helper.rb
sass-3.1.0.alpha.206 test/test_helper.rb
sass-3.1.0.alpha.205 test/test_helper.rb
sass-3.1.0.alpha.204 test/test_helper.rb
haml-3.1.0.alpha.145 vendor/sass/test/test_helper.rb
haml-3.1.0.alpha.144 vendor/sass/test/test_helper.rb
haml-3.1.0.alpha.141 vendor/sass/test/test_helper.rb
sass-3.1.0.alpha.200 test/test_helper.rb
sass-3.1.0.alpha.51 test/test_helper.rb
haml-3.1.0.alpha.37 vendor/sass/test/test_helper.rb
sass-3.1.0.alpha.50 test/test_helper.rb
sass-3.1.0.alpha.49 test/test_helper.rb