Sha256: 5207d649cd0ffcc398e679eec603c3508b243920593dab3fadccce5af7007b58

Contents?: true

Size: 685 Bytes

Versions: 3

Compression:

Stored size: 685 Bytes

Contents

require 'mida/datatype'

describe Mida::DataType::Number do

  it '#extract should raise an exception if not a number' do
    test = lambda {Mida::DataType::Number.extract('hello')}
    test.should raise_error(ArgumentError)
  end

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

  it '#extract? should return the input value as a number if a floating point' do
    Mida::DataType::Number.extract("3.14").should == 3.14
  end

  it '#extract? should return the input value as a number if a integer' do
    Mida::DataType::Number.extract("3").should == 3
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mida-0.3.2 spec/datatype/number_spec.rb
mida-0.3.1 spec/datatype/number_spec.rb
mida-0.3.0 spec/datatype/number_spec.rb