Sha256: 7bfb09de2e6d6ea21d5ee5c7e1a48dcca8a668e7a3678e751cd8513386f97a7b

Contents?: true

Size: 1.93 KB

Versions: 16

Compression:

Stored size: 1.93 KB

Contents

shared_examples_for 'supporting ByteArray' do

  before :all do
    setup_test_environment
  end

  before do
    @connection = DataObjects::Connection.new(CONFIG.uri)
  end

  after do
    @connection.close
  end

  describe 'reading a ByteArray' do

    describe 'with automatic typecasting' do

      before do
        @reader = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
        @reader.next!
        @values = @reader.values
      end

      after do
        @reader.close
      end

      it 'should return the correctly typed result' do
        @values.first.should be_kind_of(::Extlib::ByteArray)
      end

      it 'should return the correct result' do
        @values.first.should == "CAD \001 \000 DRAWING"
      end

    end

    describe 'with manual typecasting' do

      before do
        @command = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?")
        @command.set_types(::Extlib::ByteArray)
        @reader = @command.execute_reader('Buy this product now!')
        @reader.next!
        @values = @reader.values
      end

      after do
        @reader.close
      end

      it 'should return the correctly typed result' do
        @values.first.should be_kind_of(::Extlib::ByteArray)
      end

      it 'should return the correct result' do
        @values.first.should == "CAD \001 \000 DRAWING"
      end

    end

  end

  describe 'writing a ByteArray' do

    before do
      @reader = @connection.create_command("SELECT ad_description FROM widgets WHERE cad_drawing = ?").execute_reader(::Extlib::ByteArray.new("CAD \001 \000 DRAWING"))
      @reader.next!
      @values = @reader.values
    end

    after do
      @reader.close
    end

    it 'should return the correct entry' do
      #Some of the drivers starts autoincrementation from 0 not 1
      @values.first.should == 'Buy this product now!'
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
data_objects-0.10.17 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.16 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.15 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.14 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.13 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.12 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.11 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.10 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.9 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.8 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.7 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.6 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.5 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.4 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.4.rc2 lib/data_objects/spec/shared/typecast/byte_array_spec.rb
data_objects-0.10.4.rc1 lib/data_objects/spec/shared/typecast/byte_array_spec.rb