spec/adapters/sqlite_spec.rb in sequel-0.4.3 vs spec/adapters/sqlite_spec.rb in sequel-0.4.4
- old
+ new
@@ -4,10 +4,14 @@
SQLITE_DB.create_table :items do
integer :id, :primary_key => true, :auto_increment => true
text :name
float :value
end
+SQLITE_DB.create_table :test2 do
+ text :name
+ integer :value
+end
SQLITE_DB.create_table(:time) {timestamp :t}
context "An SQLite database" do
setup do
@db = Sequel('sqlite:/')
@@ -304,5 +308,38 @@
SQLITE_DB[:test].select(:name, :value).order(:value).to_a.should == \
@d.select(:name, :value).order(:value).to_a
end
end
+context "A SQLite database" do
+ setup do
+ @db = SQLITE_DB
+ end
+
+ specify "should support add_column operations" do
+ @db.add_column :test2, :xyz, :text
+
+ @db[:test2].columns.should == [:name, :value, :xyz]
+ @db[:test2] << {:name => 'mmm', :value => 111}
+ @db[:test2].first[:xyz].should == '000'
+ end
+
+ specify "should not support drop_column operations" do
+ proc {@db.drop_column :test2, :xyz}.should raise_error(SequelError)
+ end
+
+ specify "should not support rename_column operations" do
+ @db[:test2].delete
+ @db.add_column :test2, :xyz, :text, :default => '000'
+ @db[:test2] << {:name => 'mmm', :value => 111, :xyz => 'qqqq'}
+
+ @db[:test2].columns.should == [:name, :value, :xyz]
+ proc {@db.rename_column :test2, :xyz, :zyx}.should raise_error(SequelError)
+ end
+
+ specify "should not support set_column_type operations" do
+ @db.add_column :test2, :xyz, :float
+ @db[:test2].delete
+ @db[:test2] << {:name => 'mmm', :value => 111, :xyz => 56.78}
+ proc {@db.set_column_type :test2, :xyz, :integer}.should raise_error(SequelError)
+ end
+end