Sha256: 0a501b6e1de97d99d9c254f6f272e621041081feddf6563d44445ce1e21b1a5b

Contents?: true

Size: 1.8 KB

Versions: 9

Compression:

Stored size: 1.8 KB

Contents

require 'assert'
require 'assert/assertions'

require 'assert/utils'

module Assert::Assertions

  class AssertIncludesTests < Assert::Context
    desc "`assert_includes`"
    setup do
      desc = @desc = "assert includes fail desc"
      args = @args = [ 2, [ 1 ], desc ]
      @test = Factory.test do
        assert_includes(1, [ 1 ]) # pass
        assert_includes(*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[2]}\n"\
            "Expected #{Assert::U.show(@args[1], @c)}"\
            " to include #{Assert::U.show(@args[0], @c)}."
      assert_equal exp, subject.fail_results.first.message
    end

  end

  class AssertNotIncludedTests < Assert::Context
    desc "`assert_not_included`"
    setup do
      desc = @desc = "assert not included fail desc"
      args = @args = [ 1, [ 1 ], desc ]
      @test = Factory.test do
        assert_not_included(2, [ 1 ]) # pass
        assert_not_included(*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[2]}\n"\
            "Expected #{Assert::U.show(@args[1], @c)}"\
            " to not include #{Assert::U.show(@args[0], @c)}."
      assert_equal exp, subject.fail_results.first.message
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
assert-2.15.2 test/unit/assertions/assert_includes_tests.rb
assert-2.15.1 test/unit/assertions/assert_includes_tests.rb
assert-2.15.0 test/unit/assertions/assert_includes_tests.rb
assert-2.14.0 test/unit/assertions/assert_includes_tests.rb
assert-2.13.0 test/unit/assertions/assert_includes_tests.rb
assert-2.12.2 test/unit/assertions/assert_includes_tests.rb
assert-2.12.1 test/unit/assertions/assert_includes_tests.rb
assert-2.12.0 test/unit/assertions/assert_includes_tests.rb
assert-2.11.0 test/unit/assertions/assert_includes_tests.rb