spec/adapters/sqlite_spec.rb in sequel-2.11.0 vs spec/adapters/sqlite_spec.rb in sequel-2.12.0
- old
+ new
@@ -81,11 +81,11 @@
# no commit
@db.tables.should_not include(:u)
proc {@db.transaction do
@db.create_table!(:v) {text :name}
- raise Sequel::Error::Rollback
+ raise Sequel::Rollback
end}.should_not raise_error
# no commit
@db.tables.should_not include(:r)
end
@@ -99,11 +99,11 @@
@db.tables.should include(:t)
proc {@db.transaction do
@db.create_table!(:v) {text :name}
@db.transaction do
- raise Sequel::Error::Rollback # should roll back the top-level transaction
+ raise Sequel::Rollback # should roll back the top-level transaction
end
end}.should_not raise_error
# no commit
@db.tables.should_not include(:v)
end
@@ -136,12 +136,12 @@
t1 = Time.at(1)
@db[:time] << {:t => t1, :d => t1.to_i}
@db[:time] << {:t => t1.to_i, :d => t1}
@db[:time].map(:t).should == [t1, t1]
@db[:time].map(:d).should == [t1, t1]
- t2 = t1.iso8601.to_datetime
Sequel.datetime_class = DateTime
+ t2 = Sequel.string_to_datetime(t1.iso8601)
@db[:time].map(:t).should == [t2, t2]
@db[:time].map(:d).should == [t2, t2]
end
specify "should support sequential primary keys" do
@@ -167,19 +167,14 @@
specify "should correctly parse the schema" do
@db.create_table!(:time2) {timestamp :t}
@db.schema(:time2, :reload=>true).should == [[:t, {:type=>:datetime, :allow_null=>true, :default=>nil, :db_type=>"timestamp", :primary_key=>false}]]
end
-
- specify "should get the schema all database tables if no table name is used" do
- @db.create_table!(:time2) {timestamp :t}
- @db.schema(:time2, :reload=>true).should == @db.schema(nil, :reload=>true)[:time2]
- end
end
context "An SQLite dataset" do
- setup do
+ before do
SQLITE_DB.create_table! :items do
integer :id, :primary_key => true, :auto_increment => true
text :name
float :value
end
@@ -287,11 +282,11 @@
SQLITE_DB[:t].join_table(:natural, :j, nil, :a).sql.should == "SELECT * FROM t NATURAL JOIN j AS 'a'"
end
end
context "An SQLite dataset" do
- setup do
+ before do
SQLITE_DB.create_table! :items do
integer :id, :primary_key => true, :auto_increment => true
text :name
float :value
end
@@ -318,11 +313,11 @@
@d.min(:value).to_s.should == 1.23.to_s
end
end
context "SQLite::Dataset#delete" do
- setup do
+ before do
SQLITE_DB.create_table! :items do
integer :id, :primary_key => true, :auto_increment => true
text :name
float :value
end
@@ -333,14 +328,14 @@
@d << {:name => 'ghi', :value => 7.89}
end
specify "should return the number of records affected when filtered" do
@d.count.should == 3
- @d.filter {:value.sql_number < 3}.delete.should == 1
+ @d.filter(:value.sql_number < 3).delete.should == 1
@d.count.should == 2
- @d.filter {:value.sql_number < 3}.delete.should == 0
+ @d.filter(:value.sql_number < 3).delete.should == 0
@d.count.should == 2
end
specify "should return the number of records affected when unfiltered" do
@d.count.should == 3
@@ -350,11 +345,11 @@
@d.delete.should == 0
end
end
context "SQLite::Dataset#update" do
- setup do
+ before do
SQLITE_DB.create_table! :items do
integer :id, :primary_key => true, :auto_increment => true
text :name
float :value
end
@@ -373,11 +368,11 @@
@d.filter(:name => 'xxx').update(:value => 23).should == 0
end
end
context "SQLite dataset" do
- setup do
+ before do
SQLITE_DB.create_table! :test do
integer :id, :primary_key => true, :auto_increment => true
text :name
float :value
end
@@ -391,11 +386,11 @@
@d << {:name => 'abc', :value => 1.23}
@d << {:name => 'def', :value => 4.56}
@d << {:name => 'ghi', :value => 7.89}
end
- teardown do
+ after do
SQLITE_DB.drop_table :test
end
specify "should be able to insert from a subquery" do
SQLITE_DB[:test] << @d
@@ -404,10 +399,10 @@
@d.select(:name, :value).order(:value).to_a
end
end
context "A SQLite database" do
- setup do
+ before do
@db = SQLITE_DB
@db.create_table! :test2 do
text :name
integer :value
end