Sha256: 785d1aa0f995af8d97e2e494f1ee0c4a79cbd1aa3bd74751c1844b7f112c4a2d

Contents?: true

Size: 906 Bytes

Versions: 1

Compression:

Stored size: 906 Bytes

Contents

$LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
require "str2duck"
require 'minitest/autorun'
describe 'StringParse' do

  specify 'parse objects into the right format' do

    {
        "2011-03-12" => Date,
        "2007-07-20 18:59:27 +0200" => Time,
        "2010-10-30 18:02:56 +0200" => Time,
        "2012-09-12T14:49:50+02:00" => DateTime,
        "123" => Fixnum,
        "asd" => String,
        "123.432" => Float,
        "123,432" => Float,
        "true" => TrueClass,
        "false" => FalseClass,
        "some string data" => String,
        "--- hello\n..." => String,
        "2014-11-04T15:46:06Z" => DateTime
    }.each_pair do |str, klass|
      str.to_duck.must_be_instance_of klass
    end

  end

  specify 'when checking json' do
    require 'json'
    "{\"hello\":\"json\"}".to_duck.must_be_instance_of Hash
    '["dog","cat"]'.to_duck.must_be_instance_of Array
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
str2duck-2.0.0 test/test_parse.rb