Sha256: 7f46ff7cd819249e07ab98fe8de7dcd3b1e5848fd09a0957148aeb5d646d25dd

Contents?: true

Size: 775 Bytes

Versions: 6

Compression:

Stored size: 775 Bytes

Contents

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

describe "COPY TO BINARY" do
  before(:all) do
    ActiveRecord::Base.connection.execute %{
      TRUNCATE TABLE test_models;
      SELECT setval('test_models_id_seq', 1, false);
}
    TestModel.create :data => 'text'
  end

  describe "should allow binary output to string" do
    context "with only binary option" do
      subject{ TestModel.copy_to_string(:format => :binary) }
      it{ should == File.open('spec/fixtures/2_col_binary_data.dat', 'r:ASCII-8BIT').read }
    end
    context "with custom select" do
      subject{ TestModel.select("id, data").copy_to_string(:format => :binary) }
      it{ should == File.open('spec/fixtures/2_col_binary_data.dat', 'r:ASCII-8BIT').read }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
postgres-copy-1.7.2 spec/copy_to_binary_spec.rb
postgres-copy-1.7.1 spec/copy_to_binary_spec.rb
postgres-copy-1.7.0 spec/copy_to_binary_spec.rb
postgres-copy-1.6.1 spec/copy_to_binary_spec.rb
postgres-copy-1.6.0 spec/copy_to_binary_spec.rb
postgres-copy-1.5.0 spec/copy_to_binary_spec.rb