Sha256: db55b41114a4a43a27a0450588fa64f61429a75f551a7eae4f63820ec954b672

Contents?: true

Size: 811 Bytes

Versions: 20

Compression:

Stored size: 811 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "COPY FROM BINARY" do
  before(:each) do
    ActiveRecord::Base.connection.execute %{
      TRUNCATE TABLE test_models;
      SELECT setval('test_models_id_seq', 1, false);
}
  end

  it "should import from file if path is passed without field_map" do
    TestModel.copy_from File.expand_path('spec/fixtures/2_col_binary_data.dat'), :format => :binary, columns: [:id, :data]
    TestModel.order(:id).map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'text'}]
  end

  it "should import from file if columns are not specified" do
    TestModel.copy_from File.expand_path('spec/fixtures/2_col_binary_data.dat'), :format => :binary
    TestModel.order(:id).map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'text'}]
  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
postgres-copy-1.7.2 spec/copy_from_binary_spec.rb
postgres-copy-1.7.1 spec/copy_from_binary_spec.rb
postgres-copy-1.7.0 spec/copy_from_binary_spec.rb
postgres-copy-1.6.1 spec/copy_from_binary_spec.rb
postgres-copy-1.6.0 spec/copy_from_binary_spec.rb
postgres-copy-1.5.0 spec/copy_from_binary_spec.rb
postgres-copy-1.4.1 spec/copy_from_binary_spec.rb
postgres-copy-1.4.0 spec/copy_from_binary_spec.rb
postgres-copy-1.3.0 spec/copy_from_binary_spec.rb
postgres-copy-1.2.0 spec/copy_from_binary_spec.rb
postgres-copy-1.1.2 spec/copy_from_binary_spec.rb
postgres-copy-1.1.1 spec/copy_from_binary_spec.rb
postgres-copy-1.1.0 spec/copy_from_binary_spec.rb
postgres-copy-1.0.0 spec/copy_from_binary_spec.rb
postgres-copy-0.9.3 spec/copy_from_binary_spec.rb
postgres-copy-0.9.2 spec/copy_from_binary_spec.rb
postgres-copy-0.9.1 spec/copy_from_binary_spec.rb
postgres-copy-0.9.0 spec/copy_from_binary_spec.rb
postgres-copy-0.8.1 spec/copy_from_binary_spec.rb
postgres-copy-0.8.0 spec/copy_from_binary_spec.rb