Sha256: 087d3c359b3b3b3c3be33ba917ff019860fef9341ab5961e50bf009d6c3681bf

Contents?: true

Size: 1.62 KB

Versions: 17

Compression:

Stored size: 1.62 KB

Contents

require 'assert'
require 'assert/assertions'

require 'assert/utils'

module Assert::Assertions

  class AssertEmptyTests < Assert::Context
    desc "`assert_empty`"
    setup do
      desc = @desc = "assert empty fail desc"
      args = @args = [ [ 1 ], desc ]
      @test = Factory.test do
        assert_empty([])    # pass
        assert_empty(*args) # fail
      end
      @c = @test.config
      @test.run
    end
    subject{ @test }

    should "produce results as expected" do
      assert_equal 2, subject.result_count
      assert_equal 1, subject.result_count(:pass)
      assert_equal 1, subject.result_count(:fail)
    end

    should "have a fail message with custom and generic explanations" do
      exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to be empty."
      assert_equal exp, subject.fail_results.first.message
    end

  end

  class AssertNotEmptyTests < Assert::Context
    desc "`assert_not_empty`"
    setup do
      desc = @desc = "assert not empty fail desc"
      args = @args = [ [], desc ]
      @test = Factory.test do
        assert_not_empty([ 1 ]) # pass
        assert_not_empty(*args) # fail
      end
      @c = @test.config
      @test.run
    end
    subject{ @test }

    should "produce results as expected" do
      assert_equal 2, subject.result_count
      assert_equal 1, subject.result_count(:pass)
      assert_equal 1, subject.result_count(:fail)
    end

    should "have a fail message with custom and generic explanations" do
      exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not be empty."
      assert_equal exp, subject.fail_results.first.message
    end

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
assert-2.15.2 test/unit/assertions/assert_empty_tests.rb
assert-2.15.1 test/unit/assertions/assert_empty_tests.rb
assert-2.15.0 test/unit/assertions/assert_empty_tests.rb
assert-2.14.0 test/unit/assertions/assert_empty_tests.rb
assert-2.13.0 test/unit/assertions/assert_empty_tests.rb
assert-2.12.2 test/unit/assertions/assert_empty_tests.rb
assert-2.12.1 test/unit/assertions/assert_empty_tests.rb
assert-2.12.0 test/unit/assertions/assert_empty_tests.rb
assert-2.11.0 test/unit/assertions/assert_empty_tests.rb
assert-2.10.1 test/unit/assertions/assert_empty_tests.rb
assert-2.10.0 test/unit/assertions/assert_empty_tests.rb
assert-2.9.0 test/unit/assertions/assert_empty_tests.rb
assert-2.8.0 test/unit/assertions/assert_empty_tests.rb
assert-2.7.1 test/unit/assertions/assert_empty_tests.rb
assert-2.7.0 test/unit/assertions/assert_empty_tests.rb
assert-2.6.0 test/unit/assertions/assert_empty_tests.rb
assert-2.5.0 test/unit/assertions/assert_empty_tests.rb