Skip to content

Commit

Permalink
Switch to Minitest
Browse files Browse the repository at this point in the history
This way we're sure to be using the same test library on all Ruby
versions and platforms.
  • Loading branch information
norman committed Apr 30, 2012
1 parent 500d28f commit ea8b22f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions haml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rails'
spec.add_development_dependency 'ruby_parser'
spec.add_development_dependency 'rbench'
spec.add_development_dependency 'minitest'

spec.description = <<-END
Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
Expand Down
6 changes: 3 additions & 3 deletions test/engine_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/test_helper'

class EngineTest < Test::Unit::TestCase
class EngineTest < MiniTest::Unit::TestCase
# A map of erroneous Haml documents to the error messages they should produce.
# The error messages may be arrays;
# if so, the second element should be the line number that should be reported for the error.
Expand Down Expand Up @@ -1434,7 +1434,7 @@ def test_xhtml_output_option
end

def test_arbitrary_output_option
assert_raise_message(Haml::Error, "Invalid output format :html1") do
assert_raises_message(Haml::Error, "Invalid output format :html1") do
engine("%br", :format => :html1)
end
end
Expand Down Expand Up @@ -1484,7 +1484,7 @@ def test_html_has_different_doctype

# because anything before the doctype triggers quirks mode in IE
def test_xml_prolog_and_doctype_dont_result_in_a_leading_whitespace_in_html
assert_no_match(/^\s+/, render("!!! xml\n!!!", :format => :html4))
refute_match(/^\s+/, render("!!! xml\n!!!", :format => :html4))
end

# HTML5
Expand Down
12 changes: 6 additions & 6 deletions test/helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def something_that_uses_haml_concat
end
end

class HelperTest < Test::Unit::TestCase
class HelperTest < MiniTest::Unit::TestCase
Post = Struct.new('Post', :body, :error_field, :errors)
class PostErrors
def on(name)
Expand Down Expand Up @@ -289,19 +289,19 @@ def test_haml_tag_renders_text_on_a_single_line
end

def test_haml_tag_raises_error_for_multiple_content
assert_raise(Haml::Error) { render("- haml_tag :p, 'foo' do\n bar") }
assert_raises(Haml::Error) { render("- haml_tag :p, 'foo' do\n bar") }
end

def test_haml_tag_flags
assert_equal("<p />\n", render("- haml_tag :p, :/"))
assert_equal("<p>kumquat</p>\n", render("- haml_tag :p, :< do\n kumquat"))

assert_raise(Haml::Error) { render("- haml_tag :p, 'foo', :/") }
assert_raise(Haml::Error) { render("- haml_tag :p, :/ do\n foo") }
assert_raises(Haml::Error) { render("- haml_tag :p, 'foo', :/") }
assert_raises(Haml::Error) { render("- haml_tag :p, :/ do\n foo") }
end

def test_haml_tag_error_return
assert_raise(Haml::Error) { render("= haml_tag :p") }
assert_raises(Haml::Error) { render("= haml_tag :p") }
end

def test_haml_tag_with_multiline_string
Expand Down Expand Up @@ -417,7 +417,7 @@ def test_content_tag_nested
end

def test_error_return
assert_raise(Haml::Error, <<MESSAGE) {render("= haml_concat 'foo'")}
assert_raises(Haml::Error, <<MESSAGE) {render("= haml_concat 'foo'")}
haml_concat outputs directly to the Haml template.
Disregard its return value and use the - operator,
or use capture_haml to get the value as a String.
Expand Down
2 changes: 1 addition & 1 deletion test/html2haml_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require File.dirname(__FILE__) + '/html2haml/erb_tests'
require 'haml/html'

class Html2HamlTest < Test::Unit::TestCase
class Html2HamlTest < MiniTest::Unit::TestCase
def test_empty_render_should_remain_empty
assert_equal '', render('')
end
Expand Down
6 changes: 3 additions & 3 deletions test/template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def controller_path
end
end

class TemplateTest < Test::Unit::TestCase
class TemplateTest < MiniTest::Unit::TestCase
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
TEMPLATES = %w{ very_basic standard helpers
whitespace_handling original_engine list helpful
Expand Down Expand Up @@ -194,7 +194,7 @@ def test_template_renders_should_eval

unless Haml::Util.ap_geq_3?
def test_form_for_error_return
assert_raise(Haml::Error) { render(<<HAML) }
assert_raises(Haml::Error) { render(<<HAML) }
= form_for :article, @article, :url => '' do |f|
Title:
= f.text_field :title
Expand All @@ -204,7 +204,7 @@ def test_form_for_error_return
end

def test_form_tag_error_return
assert_raise(Haml::Error) { render(<<HAML) }
assert_raises(Haml::Error) { render(<<HAML) }
= form_tag '' do
Title:
Body:
Expand Down
9 changes: 5 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'rubygems'
require 'bundler/setup'
require "test/unit" # On JRuby, tests won't run unless we include this WTF
require 'minitest/autorun'
require 'action_pack'
require 'action_controller'
require 'action_view'
Expand All @@ -19,15 +21,14 @@ class TestApp < Rails::Application

ActionController::Base.logger = Logger.new(nil)

require 'test/unit'
require 'fileutils'
require 'haml'

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

class Test::Unit::TestCase
class MiniTest::Unit::TestCase
def assert_warning(message)
the_real_stderr, $stderr = $stderr, StringIO.new
yield
Expand Down Expand Up @@ -73,7 +74,7 @@ def rails_form_opener
'" type="hidden" value="' + char + '" /></div>'
end

def assert_raise_message(klass, message)
def assert_raises_message(klass, message)
yield
rescue Exception => e
assert_instance_of(klass, e)
Expand All @@ -82,7 +83,7 @@ def assert_raise_message(klass, message)
flunk "Expected exception #{klass}, none raised"
end

def assert_raise_line(line)
def assert_raises_line(line)
yield
rescue Sass::SyntaxError => e
assert_equal(line, e.sass_line)
Expand Down
2 changes: 1 addition & 1 deletion test/util_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/test_helper'
require 'pathname'

class UtilTest < Test::Unit::TestCase
class UtilTest < MiniTest::Unit::TestCase
include Haml::Util

class Dumpable
Expand Down

0 comments on commit ea8b22f

Please sign in to comment.