Sha256: 4cda12a96342d78fa81f0eab77d6994aa34c6ff22448ef3fcf0ef7c30d80e65b

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe "SET datatype" do

  describe "schema dump", :db_support => true do
    before { load_schema "set_old" }
    subject { dumped_schema }

    it "dumps native format" do
      subject.should match %r{t\.set\s+"gadgets",\s+:limit => \["propeller", "tail gun", "gps"\]}
    end

    it "dumps default option" do
      subject.should match %r{t\.set\s+"gadgets",.+:default => \["propeller", "gps"\]}
    end

    it "dumps null option" do
      subject.should match %r{t\.set\s+"gadgets",.+:null => false$}
    end
  end

  describe "schema loading" do
    before { load_schema "set_new" }
    subject { column_props :balloons, :ribbons }

    it "loads native format", :db_support => true do
      subject[ :type ].should == "set('red','green','gold')"
    end

    it "falls back to text when missing db support", :db_support => false do
      subject[ :type ].should =~ /varchar/
    end

    it "loads default option" do
      subject[ :default ].should == "green,gold"
    end

    it "loads null option" do
      subject[ :null ].should be_false
    end

    it "loads native column format", :db_support => true do
      subject = column_props :balloons, :gasses
      subject[ :type ].should == "set('helium','hydrogen')"
    end
  end
end

class Balloon < ActiveRecord::Base; end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord_enum-0.2.0 spec/set_spec.rb
activerecord_enum-0.1.1 spec/set_spec.rb
activerecord_enum-0.1.0 spec/set_spec.rb
activerecord_enum-0.0.3 spec/set_spec.rb