Sha256: 3649e5c901c6529cea4c3c3d940da7473fd14a4897da815cf3cc739ea1d61ab3

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby

# boolean.rb
# Kernel#boolean? unit tests

require 'test/unit'

require 'pathname'
dir = Pathname.new(File.expand_path(__FILE__)).realpath
require File.join(File.dirname(dir.to_s), '../lib/rex')

class BooleanTests < Test::Unit::TestCase
  def test_true
    expected = true
    actual = nil

    assert_nothing_raised do
      actual = true.boolean?
    end

    assert_not_nil(actual)
    assert_instance_of(TrueClass, actual)
    assert_equal(expected, actual)
  end

  def test_false
    expected = true
    actual = nil

    assert_nothing_raised do
      actual = false.boolean?
    end

    assert_not_nil(actual)
    assert_instance_of(TrueClass, actual)
    assert_equal(expected, actual)
  end

  def test_string
    expected = false
    actual = nil

    assert_nothing_raised do
      actual = 'la la la'.boolean?
    end

    assert_not_nil(actual)
    assert_instance_of(FalseClass, actual)
    assert_equal(expected, actual)
  end

  def test_nil
    expected = nil
    actual = nil

    assert_raise(ArgumentError) do
      actual = nil.boolean?
    end

    assert_nil(actual)
    assert_instance_of(NilClass, actual)
    assert_equal(expected, actual)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rex-0.0.4 test/boolean.rb