Sha256: 3c350783eac80ad31ae8ea6dad4a6b8f648cc3ab869611385b238d47ebc670d8

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

require 'helper'

class TestAttribute < Test::Unit::TestCase
  context '#value_from_row' do
    setup do
      @airport = Airport.new
    end
    context 'nullify is true' do
      setup do
        @attribute = DataMiner::Attribute.new @airport, 'latitude', :nullify => true
      end
      should 'return nil if field is blank' do
        assert_nil @attribute.value_from_row(
          'name' => 'DTW',
          'city' => 'Warren',
          'country_name' => 'US',
          'latitude' => '',
          'longitude' => ''
        )
      end
      should 'return the value if field is not blank' do
        assert_equal '12.34', @attribute.value_from_row(
          'name' => 'DTW',
          'city' => 'Warren',
          'country_name' => 'US',
          'latitude' => '12.34',
          'longitude' => ''
        )
      end
    end
    context 'nullify is false' do
      setup do
        @attribute = DataMiner::Attribute.new @airport, 'latitude'
      end
      should 'return the value if field is not blank' do
        assert_equal '12.34', @attribute.value_from_row(
          'name' => 'DTW',
          'city' => 'Warren',
          'country_name' => 'US',
          'latitude' => '12.34',
          'longitude' => ''
        )
      end
      should 'return blank if field is blank' do
        assert_equal '', @attribute.value_from_row(
          'name' => 'DTW',
          'city' => 'Warren',
          'country_name' => 'US',
          'latitude' => '',
          'longitude' => ''
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
data_miner-1.1.2 test/test_attribute.rb
data_miner-1.1.1 test/test_attribute.rb
data_miner-1.1.0 test/test_attribute.rb
data_miner-1.0.1 test/test_attribute.rb
data_miner-1.0.0 test/test_attribute.rb