Sha256: 9ebcc3dea023ec37450fd94462c464cec29c5c1b568bd19f2f70b1ba190811b8

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

describe Importer::Row do

  before do
    @importer = Importer.new
    @row = Importer::Row.new(@importer, 5)
  end

  it 'should store and retrieve values' do
    @row.set_values(:a => 1, :b => 2)
    @row.values.should == {:a => 1, :b => 2}
  end

  it 'should allow [] access' do
    @row.set_values(:a => 1, :b => 2)
    @row[:b].should == 2
  end

  it 'should test for value presence in all columns' do
    @row.set_values(:a => 1, :b => 2)
    @row.should be_all
    @row.set_values(:a => 1, :b => nil)
    @row.should_not be_all
  end

  it 'should test for specific value\'s presence' do
    @row.set_values(:a => 1, :b => 2, :c => nil)
    @row.all?(:a, :b).should be_true
    @row.all?(:c).should be_false
  end

  it 'should be empty? with zero values' do
    @row.set_values(:a => nil, :b => nil)
    @row.should be_empty
  end
  
  it 'should return nil on missing data' do
    @row.set_values(:a => 1, :b => 2)
    @row[:c].should be_nil
  end
  
  it 'should not change when to_hash values are changed' do
    @row.set_values(:a => 1, :b => 2)
    hash = @row.to_hash
    hash.should == {:a => 1, :b => 2}
    hash.delete(:a)
    @row[:a].should == 1
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iron-import-0.8.8 spec/importer/row_spec.rb
iron-import-0.8.7 spec/importer/row_spec.rb
iron-import-0.8.6 spec/importer/row_spec.rb
iron-import-0.8.5 spec/importer/row_spec.rb
iron-import-0.8.4 spec/importer/row_spec.rb
iron-import-0.8.3 spec/importer/row_spec.rb
iron-import-0.8.2 spec/importer/row_spec.rb
iron-import-0.8.1 spec/importer/row_spec.rb
iron-import-0.8.0 spec/importer/row_spec.rb