Sha256: 9a01cc0352997e00bd42b2665d59ce1d92f83736e15c9559239535369367b4e4

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

# Copyright (c) 2011 Pluron, Inc.

require 'test/unit'
require 'assure'

class AssureTest < Test::Unit::TestCase

    def test_basic
        assure("Test".is_a? String)

        exception = assert_raise(RuntimeError) do
            assure(false)
        end
        assert_equal 'test/assure_test.rb:12: test_basic: Assertion "false" failed', exception.message

        exception = assert_raise(RuntimeError) do
            assure(nil)
        end
        assert_equal 'test/assure_test.rb:17: test_basic: Assertion "nil" failed', exception.message

        exception = assert_raise(RuntimeError) do
            x = 2
            assure( x == 3, "#{x} == 2" )
        end
        assert_equal "test/assure_test.rb:23: test_basic: Assertion \"x == 3, \"\#{x} == 2\"\" failed\n2 == 2", exception.message

        exception = assert_raise(RuntimeError) do
            assure(1.is_a? String)
        end
        assert_equal 'test/assure_test.rb:28: test_basic: Assertion "1.is_a? String" failed', exception.message
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
assure-0.1.2 test/assure_test.rb
assure-0.1.1 test/assure_test.rb