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

Version Path
assert-2.0.0.rc.1 test/assertions/assert_nothing_raised_test.rb
assert-1.1.0 test/assertions/assert_nothing_raised_test.rb
assert-1.0.0 test/assertions/assert_nothing_raised_test.rb
assert-0.8.1 test/assertions/assert_nothing_raised_test.rb
assert-0.8.0 test/assertions/assert_nothing_raised_test.rb
assert-0.7.3 test/assertions/assert_nothing_raised_test.rb
assert-0.7.2 test/assertions/assert_nothing_raised_test.rb
assert-0.7.1 test/assertions/assert_nothing_raised_test.rb
assert-0.7.0 test/assertions/assert_nothing_raised_test.rb
assert-0.6.0 test/assertions/assert_nothing_raised_test.rb
assert-0.5.0 test/assertions/assert_nothing_raised_test.rb
assert-0.4.0 test/assertions/assert_nothing_raised_test.rb
assert-0.3.0 test/assertions/assert_nothing_raised_test.rb
assert-0.2.1 test/assertions/assert_nothing_raised_test.rb
assert-0.2.0 test/assertions/assert_nothing_raised_test.rb
assert-0.1.0 test/assertions/assert_nothing_raised_test.rb