Sha256: 923b1717c210510beb5a73fa08971fe24810d717087a4db3bab94f5192fef391

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

require "spec_helper"

describe Baza::Driver::Pg::Columns do
  let(:constant) do
    const_name = "InfoPg"
    require StringCases.camel_to_snake(const_name)
    raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
    Baza.const_get(const_name)
  end
  let(:db) { constant.new.db }

  describe "#data_sql" do
    it "convert int(11) to integer" do
      result = db.columns.data_sql(
        name: "test",
        type: :int,
        maxlength: 11
      )

      expect(result).to eq '"test" integer'
    end

    it "converts int with auto increment to serial" do
      result = db.columns.data_sql(
        name: "test",
        type: :int,
        maxlength: 11,
        autoincr: true
      )

      expect(result).to eq '"test" serial'
    end

    it "converts tinyint to smallint" do
      result = db.columns.data_sql(
        name: "test",
        type: :tinyint,
        maxlength: 11,
        autoincr: true
      )

      expect(result).to eq '"test" smallint'
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
baza-0.0.38 spec/drivers/pg/columns_spec.rb
baza-0.0.37 spec/drivers/pg/columns_spec.rb
baza-0.0.36 spec/drivers/pg/columns_spec.rb
baza-0.0.35 spec/drivers/pg/columns_spec.rb
baza-0.0.34 spec/drivers/pg/columns_spec.rb
baza-0.0.33 spec/drivers/pg/columns_spec.rb
baza-0.0.32 spec/drivers/pg/columns_spec.rb
baza-0.0.31 spec/drivers/pg/columns_spec.rb
baza-0.0.30 spec/drivers/pg/columns_spec.rb
baza-0.0.29 spec/drivers/pg/columns_spec.rb
baza-0.0.28 spec/drivers/pg/columns_spec.rb