Sha256: 7703e0c2889d44c195c25df0e7b13c5c0beb0e4ad619beb5ed9a3556d32f2e66

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'helper'
class StringToBoolTest < Test::Unit::TestCase
  context "String to_bool" do

    should "return true" do
      assert "true".to_bool, "true"
      assert "1".to_bool, "1"
      assert "t".to_bool, "t"
      assert "y".to_bool, "y"
      assert "yes".to_bool, "yes"
    end

    should "return false" do
      assert ! "false".to_bool, "false"
      assert ! "0".to_bool, "0"
      assert ! "f".to_bool, "f"
      assert ! "no".to_bool, "no"
      assert ! "n".to_bool, "n"
      assert ! "".to_bool, "blank string"
    end

    should "raise exception on unknown" do
      assert_raises ArgumentError do
        "unknown string".to_bool
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redis-model-extension-0.4.2 test/test_string_to_bool.rb
redis-model-extension-0.4.1 test/test_string_to_bool.rb
redis-model-extension-0.4.0 test/test_string_to_bool.rb