Sha256: 9943addd1a4aeb32396493a86eb38469ef7e6e2ebc748f3917f06b477123f18c

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'assert'

class Assert::Assertions::AssertNotKindOfTest < Assert::Context
  desc "the assert_not_kind_of helper run in a test"
  setup do
    fail_desc = @fail_desc = "assert not kind of fail desc"
    fail_args = @fail_args = [ String, "object", fail_desc ]
    @test = Factory.test do
      assert_not_kind_of(*fail_args)        # fail
      assert_not_kind_of(Array, "object")   # pass
    end
    @test.run
  end
  subject{ @test }

  should "have 2 total results" do
    assert_equal 2, subject.result_count
  end
  should "have 1 pass result" do
    assert_equal 1, subject.result_count(:pass)
  end
  should "have 1 fail result" do
    assert_equal 1, subject.result_count(:fail)
  end

  class FailMessageTest < AssertNotKindOfTest
    desc "with a failed result"
    setup do
      @expected = [
        "#{@fail_args[1].inspect} was not expected to be a kind of #{@fail_args[0]}.",
        "\n#{@fail_args[2]}"
      ].join
      @fail_message = @test.fail_results.first.message
    end
    subject{ @fail_message }

    should "have a fail message with an explanation of what failed and my fail description" do
      assert_equal @expected, subject
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
assert-0.1.0 test/assertions/assert_not_kind_of_test.rb