Sha256: 0bd53c1996fe2128ee6f10c1358a5f924fa5be0e0178b36f158d3dddc17e442e

Contents?: true

Size: 787 Bytes

Versions: 30

Compression:

Stored size: 787 Bytes

Contents

require 'test_helper'

module PushType
  class CoreExtTest < ActiveSupport::TestCase

    describe 'to_bool' do
      # Strings
      it { ''.to_bool.must_equal false }
      it { '0'.to_bool.must_equal false }
      it { 'no'.to_bool.must_equal false }
      it { 'false'.to_bool.must_equal false }
      it { '1'.to_bool.must_equal true }
      it { 'anything else'.to_bool.must_equal true }

      # Fixnums
      it { 0.to_bool.must_equal false }
      it { 1.to_bool.must_equal true }
      it { 1234.to_bool.must_equal true }

      # Booleans
      it { false.to_i.must_equal 0 }
      it { false.to_bool.must_equal false }
      it { true.to_i.must_equal 1 }
      it { true.to_bool.must_equal true }

      # Nils
      it { nil.to_bool.must_equal false }
    end
    
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
push_type_core-0.12.1 test/lib/push_type/core_exts_test.rb
push_type_core-0.12.0 test/lib/push_type/core_exts_test.rb
push_type_core-0.12.0.beta.1 test/lib/push_type/core_exts_test.rb
push_type_core-0.11.2 test/lib/push_type/core_exts_test.rb
push_type_core-0.11.1 test/lib/push_type/core_exts_test.rb
push_type_core-0.11.0.beta.2 test/lib/push_type/core_exts_test.rb
push_type_core-0.11.0.beta.1 test/lib/push_type/core_exts_test.rb
push_type_core-0.10.4 test/lib/push_type/core_exts_test.rb
push_type_core-0.10.3 test/lib/push_type/core_exts_test.rb
push_type_core-0.10.2 test/lib/push_type/core_exts_test.rb
push_type_core-0.10.1 test/lib/push_type/core_exts_test.rb
push_type_core-0.10.0 test/lib/push_type/core_exts_test.rb
push_type_core-0.10.0.beta.5 test/lib/push_type/core_exts_test.rb
push_type_core-0.10.0.beta.3 test/lib/push_type/core_exts_test.rb
push_type_core-0.9.5 test/lib/push_type/core_exts_test.rb
push_type_core-0.9.3 test/lib/push_type/core_exts_test.rb
push_type_core-0.9.2 test/lib/push_type/core_exts_test.rb
push_type_core-0.9.1 test/lib/push_type/core_exts_test.rb
push_type_core-0.9.0 test/lib/push_type/core_exts_test.rb
push_type_core-0.9.0.beta.4 test/lib/push_type/core_exts_test.rb