Sha256: 5c53d93ca09992b84f489fd339d44984bcd52954dd626bde45a4f0caedb8acd4

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 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: block in test_basic: Assertion "false" failed', exception.message

        exception = assert_raise(RuntimeError) do
            assure(nil)
        end
        assert_equal '/test/assure_test.rb:17: block in 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: block in 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: block in test_basic: Assertion "1.is_a? String" failed', exception.message
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
assure-1.0 test/assure_test.rb