Sha256: 9e35d08e6733380ff8a4999593d1c75dd1c3e17a9154aeeb2a1e4591ee3b5ef9
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Acfs::Resource::Attributes::Boolean do subject(:type) { Acfs::Resource::Attributes::Boolean.new } describe '#cast' do it 'casts nil' do expect(type.cast(nil)).to be_nil end it 'casts empty string to false' do expect(type.cast('')).to be_nil end it 'casts blank string to false' do expect(type.cast(" \t")).to be_nil end it 'preserves boolean values' do expect(type.cast(false)).to be false expect(type.cast(true)).to be true end it 'casts falsy values to false' do expect(type.cast(false)).to be false expect(type.cast(0)).to be false expect(type.cast('0')).to be false expect(type.cast('no')).to be false expect(type.cast('NO')).to be false expect(type.cast('off')).to be false expect(type.cast('OFF')).to be false expect(type.cast('false')).to be false expect(type.cast('FALSE')).to be false expect(type.cast('f')).to be false expect(type.cast('F')).to be false end it 'casts any other value to true' do expect(type.cast(true)).to be true expect(type.cast(1)).to be true expect(type.cast('1')).to be true expect(type.cast('yes')).to be true expect(type.cast('YES')).to be true expect(type.cast('on')).to be true expect(type.cast('ON')).to be true expect(type.cast('true')).to be true expect(type.cast('TRUE')).to be true expect(type.cast('t')).to be true expect(type.cast('T')).to be true expect(type.cast(2)).to be true expect(type.cast('wrong')).to be true expect(type.cast('random')).to be true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acfs-2.0.0 | spec/acfs/resource/attributes/boolean_spec.rb |