require "#{File.dirname(__FILE__)}/test_helper" describe EnrichmentDb::Helper do it 'should convert float str to float' do result = EnrichmentDb::Helper.float_str_to_float('26') assert_equal 26, result end it 'should not convert float str to float' do input = 's26' result = EnrichmentDb::Helper.float_str_to_float(input) assert_equal input, result end it 'should convert hash with float str values to float values' do input = { 'er' => '-26', 'rt' => '234567.43' } result = EnrichmentDb::Helper.hash_float_str_to_float(input) expecting = { 'er' => -26, 'rt' => 234567.43 } assert_equal expecting, result end it 'should partially convert hash with float str values to float values' do input = { 'er' => '-26', 'rt' => '23s4567.43' } result = EnrichmentDb::Helper.hash_float_str_to_float(input) expecting = { 'er' => -26, 'rt' => '23s4567.43' } assert_equal expecting, result end end