Sha256: 0a7b52cf9e60b2f9ec287946eda25814fe1a66460f1095db2280194c45f1052f

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe Hari::Entity::Serialization::Boolean do

  describe '.serialize, .desserialize' do
    it 'truthful values become true' do
      subject.serialize(true).should   be_true
      subject.serialize('true').should be_true
      subject.serialize('TRUE').should be_true
      subject.serialize('1').should    be_true
      subject.serialize(1).should      be_true
      subject.serialize(1.0).should    be_true
      subject.serialize('x').should    be_true
      subject.serialize('X').should    be_true
      subject.serialize('t').should    be_true
      subject.serialize('T').should    be_true
    end

    it 'untruthful values become false' do
      subject.serialize(false).should   be_false
      subject.serialize('false').should be_false
      subject.serialize('FALSE').should be_false
      subject.serialize('0').should     be_false
      subject.serialize(0).should       be_false
      subject.serialize(0.0).should     be_false
      subject.serialize('').should      be_false
      subject.serialize(' ').should     be_false
      subject.serialize(nil).should     be_false
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hari-0.0.5 spec/hari/entity/serialization/boolean_spec.rb
hari-0.0.4 spec/hari/entity/serialization/boolean_spec.rb
hari-0.0.3 spec/hari/entity/serialization/boolean_spec.rb
hari-0.0.1 spec/hari/entity/serialization/boolean_spec.rb