Sha256: a249055232ef014839f358d0bfcda2c9fdb2c29000ad66c4cca8c691b41cfcd9
Contents?: true
Size: 1.53 KB
Versions: 16
Compression:
Stored size: 1.53 KB
Contents
require 'assert' class Assert::Assertions::AssertNothingRaisedTest < Assert::Context desc "the assert_nothing_raised helper run in a test" setup do fail_desc = @fail_desc = "assert nothing raised fail desc" @test = Factory.test do assert_nothing_raised(StandardError, RuntimeError, fail_desc){ raise(StandardError) } # fail assert_nothing_raised(RuntimeError){ raise(StandardError) } # pass assert_nothing_raised(fail_desc){ raise(RuntimeError) } # fail assert_nothing_raised{ true } # pass end @test.run end subject{ @test } should "have 4 total results" do assert_equal 4, subject.result_count end should "have 2 pass result" do assert_equal 2, subject.result_count(:pass) end should "have 2 fail result" do assert_equal 2, subject.result_count(:fail) end class FailMessageTest < AssertNothingRaisedTest desc "with a failed result" setup do @expected = [ "#{@fail_desc}\nStandardError or RuntimeError exception was not expected, but was raised:", "#{@fail_desc}\nAn exception was not expected, but was raised:" ] @fail_messages = @test.fail_results.collect(&:message) end subject{ @fail_messages } should "have a fail message with an explanation of what failed and my fail description" do subject.each_with_index do |message, n| assert_match /^#{@expected[n]}/, message end end end end
Version data entries
16 entries across 16 versions & 1 rubygems