Sha256: bde19fdff923537a36f80c9832d3aa426ef1d19d08686d69a8277cf690d973ac

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

require 'mida_vocabulary/datatype'

describe Mida::DataType::Boolean do

  it '#parse should raise an exception if a invalid text passed' do
    test = lambda {Mida::DataType::Boolean.parse('example')}
    test.should raise_error(ArgumentError)
  end

  it '#parse should raise an exception if value is empty' do
    test = lambda {Mida::DataType::Boolean.parse('')}
    test.should raise_error(ArgumentError)
  end

  it '#parse should return true for "True" whatever the case' do
    ['true', 'True', 'TRUE', 'tRUE'].each do |true_text|
      Mida::DataType::Boolean.parse(true_text).should be_true
    end
  end

  it '#parse should return false for "False" whatever the case' do
    ['false', 'False', 'FALSE', 'fALSE'].each do |false_text|
      Mida::DataType::Boolean.parse(false_text).should be_false
    end
  end

  it '#to_s should return proper string representation of boolean' do
    Mida::DataType::Boolean.parse('fALSE').to_s.should == 'False'
    Mida::DataType::Boolean.parse('tRUE').to_s.should == 'True'
  end

  it '! should negate as if a TrueClass/FalseClass' do
    true_boolean = Mida::DataType::Boolean.parse('true')
    false_boolean = Mida::DataType::Boolean.parse('false')

    (!true_boolean).should be_false
    (!false_boolean).should be_true
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mida_vocabulary-0.2.2 spec/datatype/boolean_spec.rb
mida_vocabulary-0.2 spec/datatype/boolean_spec.rb
mida_vocabulary-0.1.3 spec/datatype/boolean_spec.rb
mida_vocabulary-0.1.2 spec/datatype/boolean_spec.rb
mida_vocabulary-0.1.1 spec/datatype/boolean_spec.rb
mida_vocabulary-0.1 spec/datatype/boolean_spec.rb