Sha256: 4a129f2ade1e6b72673267302a326e4dd665525442eff84186296652014eb845

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

require "assert"
require "assert/assertions"

module Assert::Assertions
  class AssertBlockTests < Assert::Context
    include Assert::Test::TestHelpers

    desc "`assert_block`"
    setup do
      desc = @desc = "assert block fail desc"
      @test = Factory.test do
        assert_block{ true }        # pass
        assert_block(desc){ false } # fail
      end
      @test.run(&test_run_callback)
    end
    subject{ @test }

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

    should "have a fail message with custom and generic explanations" do
      exp = "#{@desc}\nExpected block to return a true value."
      assert_equal exp, test_run_results(:fail).first.message
    end
  end

  class AssertNotBlockTests < Assert::Context
    include Assert::Test::TestHelpers

    desc "`assert_not_block`"
    setup do
      desc = @desc = "assert not block fail desc"
      @test = Factory.test do
        assert_not_block(desc){ true } # fail
        assert_not_block{ false }      # pass
      end
      @test.run(&test_run_callback)
    end
    subject{ @test }

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

    should "have a fail message with custom and generic explanations" do
      exp = "#{@desc}\nExpected block to not return a true value."
      assert_equal exp, test_run_results(:fail).first.message
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assert-2.18.2 test/unit/assertions/assert_block_tests.rb
assert-2.18.1 test/unit/assertions/assert_block_tests.rb
assert-2.18.0 test/unit/assertions/assert_block_tests.rb