Sha256: ecf8d1f2babe83eeb8e2156512bfbd3a329b98417596d77d8b91062cd0bd2b45

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require File.expand_path('test_helper.rb', File.dirname(__FILE__))

# Test behavior of overridden assert method.
class AssertTest < Test::Unit::TestCase
  def test_simple_assert
    assert { true }
  end

  def failing_block_assertion_test message, &block
    assert(&block)
  rescue Exception => e
    assert_equal message, e.message
  end

  def test_simple_failing_assert
    failing_block_assertion_test('false is false.') { false }
  end

  def test_operator_equals_assert
    foo = 24
    failing_block_assertion_test("(foo == 23) is false\nfoo is 24.") { foo == 23  }
  end

  def test_instance_variable_assert
    @foo = 24
    failing_block_assertion_test("(@foo == 23) is false\n@foo is 24.") { @foo == 23  }
  end

  # Special cases

  def test_assert_with_custom_message
    foo = false
    begin
      assert('We want foo') { foo }
    rescue Exception => e
      assert_equal "We want foo.\nfoo is false.", e.message
    end
  end

  def test_blockless_assert
    assert false
  rescue Exception => e
    assert_equal '<false> is not true.', e.message
  end

  def test_blockless_assert_with_custom_message
    assert false, 'We want the truth'
  rescue Exception => e
    assert_equal "We want the truth.\n<false> is not true.", e.message
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iba-0.0.3 test/assert_test.rb