Sha256: d885fda5db2884a5605297e4c0691ca6199a191cc705871a1395138e1482e9fa
Contents?: true
Size: 1.03 KB
Versions: 33
Compression:
Stored size: 1.03 KB
Contents
require File.expand_path('../acceptance_test_helper', __FILE__) require 'mocha' class RaiseExceptionTest < Test::Unit::TestCase include AcceptanceTest def setup setup_acceptance_test end def teardown teardown_acceptance_test end def test_should_raise_exception exception_class = Class.new(StandardError) test_result = run_as_test do foo = stub('foo') foo.stubs(:bar).raises(exception_class, "my-message") exception = assert_raises(exception_class) { foo.bar } assert_equal "my-message", exception.message end assert_passed(test_result) end def test_should_raise_two_different_exceptions exception_one_class = Class.new(StandardError) exception_two_class = Class.new(StandardError) test_result = run_as_test do foo = stub('foo') foo.stubs(:bar).raises(exception_one_class).then.raises(exception_two_class) assert_raises(exception_one_class) { foo.bar } assert_raises(exception_two_class) { foo.bar } end assert_passed(test_result) end end
Version data entries
33 entries across 28 versions & 3 rubygems