Sha256: 54cc1a2ebf54e2f38f9315ebcfc9d3f4b6296870b0e073eb27bc623a13d1ace4

Contents?: true

Size: 1.82 KB

Versions: 175

Compression:

Stored size: 1.82 KB

Contents

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

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

require 'haml/template'
Haml::Template.options[:ugly] = false
Haml::Template.options[:format] = :xhtml

class Test::Unit::TestCase
  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)
    Haml::Util.silence_warnings(&block)
  end

  def rails_block_helper_char
    return '=' if Haml::Util.ap_geq_3?
    return '-'
  end

  def form_for_calling_convention(name)
    return "@#{name}, :as => :#{name}, :html => {:class => nil, :id => nil}" if Haml::Util.ap_geq_3?
    return ":#{name}, @#{name}"
  end

  def rails_form_attr
    return 'accept-charset="UTF-8" ' if Haml::Util.ap_geq?("3.0.0.rc")
    return ''
  end

  def rails_form_opener
    return '' unless Haml::Util.ap_geq?("3.0.0.rc")
    if Haml::Util.ap_geq?("3.0.0.rc2")
      encoding = 'utf8'
      char = '✓'
    else
      encoding = '_snowman'
      char = '☃'
    end
    return '<div style="margin:0;padding:0;display:inline"><input name="' + encoding +
      '" type="hidden" value="' + char + '" /></div>'
  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

175 entries across 82 versions & 6 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.5/test/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.6/test/test_helper.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.4/test/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.4/test/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.6/test/test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.5/test/test_helper.rb
classiccms-0.7.3 vendor/bundle/gems/haml-3.1.5/test/test_helper.rb
classiccms-0.7.3 vendor/bundle/gems/haml-3.1.4/test/test_helper.rb
classiccms-0.7.3 vendor/bundle/gems/haml-3.1.6/test/test_helper.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/haml-3.1.8/test/test_helper.rb
classiccms-0.7.2 vendor/bundle/gems/haml-3.1.6/test/test_helper.rb
classiccms-0.7.2 vendor/bundle/gems/haml-3.1.4/test/test_helper.rb
classiccms-0.7.2 vendor/bundle/gems/haml-3.1.5/test/test_helper.rb
classiccms-0.7.1 vendor/bundle/gems/haml-3.1.4/test/test_helper.rb
classiccms-0.7.1 vendor/bundle/gems/haml-3.1.5/test/test_helper.rb
classiccms-0.7.1 vendor/bundle/gems/haml-3.1.6/test/test_helper.rb
classiccms-0.7.0 vendor/bundle/gems/haml-3.1.6/test/test_helper.rb
classiccms-0.7.0 vendor/bundle/gems/haml-3.1.4/test/test_helper.rb
classiccms-0.7.0 vendor/bundle/gems/haml-3.1.5/test/test_helper.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/haml-3.1.8/test/test_helper.rb