Sha256: b93a29a58559a91f3d2178ae88b65d6548f8b6eb0675bfe8eeabd63c4da69341

Contents?: true

Size: 825 Bytes

Versions: 8

Compression:

Stored size: 825 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.pg_copy_from File.expand_path('spec/fixtures/2_col_binary_data.dat'), :format => :binary, columns: [:id, :data]
    TestModel.order(:id).all.map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'text'}]
  end

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

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
postgres-copy-0.6.0 spec/pg_copy_from_binary_spec.rb
postgres-copy-0.5.8 spec/pg_copy_from_binary_spec.rb
postgres-copy-0.5.7 spec/pg_copy_from_binary_spec.rb
postgres-copy-0.5.5 spec/pg_copy_from_binary_spec.rb
postgres-copy-0.5.4 spec/pg_copy_from_binary_spec.rb
postgres-copy-0.5.3 spec/pg_copy_from_binary_spec.rb
postgres-copy-0.5.2 spec/pg_copy_from_binary_spec.rb
postgres-copy-0.5.0 spec/pg_copy_from_binary_spec.rb