spec/adapters/oracle_spec.rb in sequel-4.22.0 vs spec/adapters/oracle_spec.rb in sequel-4.23.0

- old
+ new

@@ -34,60 +34,60 @@ end after(:all) do DB.drop_table?(:items, :books, :categories, :notes) end - specify "should allow limit and offset with clob columns" do + it "should allow limit and offset with clob columns" do notes = [] notes << {:id => 1, :title => 'abc', :content => 'zyx'} notes << {:id => 2, :title => 'def', :content => 'wvu'} notes << {:id => 3, :title => 'ghi', :content => 'tsr'} notes << {:id => 4, :title => 'jkl', :content => 'qpo'} notes << {:id => 5, :title => 'mno', :content => 'nml'} DB[:notes].multi_insert(notes) - DB[:notes].sort_by{|x| x[:id]}.should == notes + DB[:notes].sort_by{|x| x[:id]}.must_equal notes rows = DB[:notes].limit(3, 0).all - rows.length.should == 3 - rows.all?{|v| notes.should include(v)} + rows.length.must_equal 3 + rows.all?{|v| notes.must_include(v)} end - specify "should provide disconnect functionality" do + it "should provide disconnect functionality" do DB.execute("select user from dual") - DB.pool.size.should == 1 + DB.pool.size.must_equal 1 DB.disconnect - DB.pool.size.should == 0 + DB.pool.size.must_equal 0 end - specify "should have working view_exists?" do + it "should have working view_exists?" do begin - DB.view_exists?(:cats).should == false + DB.view_exists?(:cats).must_equal false DB.create_view(:cats, DB[:categories]) - DB.view_exists?(:cats).should == true + DB.view_exists?(:cats).must_equal true om = DB.identifier_output_method im = DB.identifier_input_method DB.identifier_output_method = :reverse DB.identifier_input_method = :reverse - DB.view_exists?(:STAC).should == true - DB.view_exists?(:cats).should == false + DB.view_exists?(:STAC).must_equal true + DB.view_exists?(:cats).must_equal false ensure DB.identifier_output_method = om DB.identifier_input_method = im DB.drop_view(:cats) end end - specify "should be able to get current sequence value with SQL" do + it "should be able to get current sequence value with SQL" do begin DB.create_table!(:foo){primary_key :id} - DB.fetch('SELECT seq_foo_id.nextval FROM DUAL').single_value.should == 1 + DB.fetch('SELECT seq_foo_id.nextval FROM DUAL').single_value.must_equal 1 ensure DB.drop_table(:foo) end end - specify "should provide schema information" do + it "should provide schema information" do books_schema = [[:id, [:integer, false, true, nil]], [:title, [:string, false, true, nil]], [:category_id, [:integer, false, true, nil]]] categories_schema = [[:id, [:integer, false, true, nil]], [:cat_name, [:string, false, true, nil]]] @@ -95,164 +95,164 @@ [:value, [:integer, false, true, nil]], [:date_created, [:datetime, false, true, nil]]] {:books => books_schema, :categories => categories_schema, :items => items_schema}.each_pair do |table, expected_schema| schema = DB.schema(table) - schema.should_not be_nil - schema.map{|c, s| [c, s.values_at(:type, :primary_key, :allow_null, :ruby_default)]}.should == expected_schema + schema.wont_equal nil + schema.map{|c, s| [c, s.values_at(:type, :primary_key, :allow_null, :ruby_default)]}.must_equal expected_schema end end - specify "should create a temporary table" do + it "should create a temporary table" do DB.create_table! :test_tmp, :temp => true do varchar2 :name, :size => 50 primary_key :id, :integer, :null => false index :name, :unique => true end DB.drop_table?(:test_tmp) end - specify "should return the correct record count" do - @d.count.should == 0 + it "should return the correct record count" do + @d.count.must_equal 0 @d << {:name => 'abc', :value => 123} @d << {:name => 'abc', :value => 456} @d << {:name => 'def', :value => 789} - @d.count.should == 3 + @d.count.must_equal 3 end - specify "should return the correct records" do - @d.to_a.should == [] + it "should return the correct records" do + @d.to_a.must_equal [] @d << {:name => 'abc', :value => 123} @d << {:name => 'abc', :value => 456} @d << {:name => 'def', :value => 789} - @d.order(:value).to_a.should == [ + @d.order(:value).to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 123}, {:date_created=>nil, :name => 'abc', :value => 456}, {:date_created=>nil, :name => 'def', :value => 789} ] - @d.select(:name).distinct.order_by(:name).to_a.should == [ + @d.select(:name).distinct.order_by(:name).to_a.must_equal [ {:name => 'abc'}, {:name => 'def'} ] - @d.order(Sequel.desc(:value)).limit(1).to_a.should == [ + @d.order(Sequel.desc(:value)).limit(1).to_a.must_equal [ {:date_created=>nil, :name => 'def', :value => 789} ] - @d.filter(:name => 'abc').to_a.should == [ + @d.filter(:name => 'abc').order(:value).to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 123}, {:date_created=>nil, :name => 'abc', :value => 456} ] - @d.order(Sequel.desc(:value)).filter(:name => 'abc').to_a.should == [ + @d.order(Sequel.desc(:value)).filter(:name => 'abc').to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 456}, {:date_created=>nil, :name => 'abc', :value => 123} ] - @d.filter(:name => 'abc').limit(1).to_a.should == [ + @d.filter(:name => 'abc').limit(1).to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 123} ] - @d.filter(:name => 'abc').order(Sequel.desc(:value)).limit(1).to_a.should == [ + @d.filter(:name => 'abc').order(Sequel.desc(:value)).limit(1).to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 456} ] - @d.filter(:name => 'abc').order(:value).limit(1).to_a.should == [ + @d.filter(:name => 'abc').order(:value).limit(1).to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 123} ] - @d.order(:value).limit(1).to_a.should == [ + @d.order(:value).limit(1).to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 123} ] - @d.order(:value).limit(1, 1).to_a.should == [ + @d.order(:value).limit(1, 1).to_a.must_equal [ {:date_created=>nil, :name => 'abc', :value => 456} ] - @d.order(:value).limit(1, 2).to_a.should == [ + @d.order(:value).limit(1, 2).to_a.must_equal [ {:date_created=>nil, :name => 'def', :value => 789} ] - @d.avg(:value).to_i.should == (789+123+456)/3 + @d.avg(:value).to_i.must_equal((789+123+456)/3) - @d.max(:value).to_i.should == 789 + @d.max(:value).to_i.must_equal 789 - @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).filter(:name => 'abc').group(:name).to_a.should == [ + @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).filter(:name => 'abc').group(:name).to_a.must_equal [ {:name => 'abc', :avg => (456+123)/2.0} ] - @d.select(Sequel.function(:AVG, :value).as(:avg)).group(:name).order(:name).limit(1).to_a.should == [ + @d.select(Sequel.function(:AVG, :value).as(:avg)).group(:name).order(:name).limit(1).to_a.must_equal [ {:avg => (456+123)/2.0} ] - @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).group(:name).order(:name).to_a.should == [ + @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).group(:name).order(:name).to_a.must_equal [ {:name => 'abc', :avg => (456+123)/2.0}, {:name => 'def', :avg => 789*1.0} ] - @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).group(:name).order(:name).to_a.should == [ + @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).group(:name).order(:name).to_a.must_equal [ {:name => 'abc', :avg => (456+123)/2.0}, {:name => 'def', :avg => 789*1.0} ] - @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).group(:name).having(:name => ['abc', 'def']).order(:name).to_a.should == [ + @d.select(:name, Sequel.function(:AVG, :value).as(:avg)).group(:name).having(:name => ['abc', 'def']).order(:name).to_a.must_equal [ {:name => 'abc', :avg => (456+123)/2.0}, {:name => 'def', :avg => 789*1.0} ] - @d.select(:name, :value).filter(:name => 'abc').union(@d.select(:name, :value).filter(:name => 'def')).order(:value).to_a.should == [ + @d.select(:name, :value).filter(:name => 'abc').union(@d.select(:name, :value).filter(:name => 'def')).order(:value).to_a.must_equal [ {:name => 'abc', :value => 123}, {:name => 'abc', :value => 456}, {:name => 'def', :value => 789} ] end - specify "should update records correctly" do + it "should update records correctly" do @d << {:name => 'abc', :value => 123} @d << {:name => 'abc', :value => 456} @d << {:name => 'def', :value => 789} @d.filter(:name => 'abc').update(:value => 530) - @d[:name => 'def'][:value].should == 789 - @d.filter(:value => 530).count.should == 2 + @d[:name => 'def'][:value].must_equal 789 + @d.filter(:value => 530).count.must_equal 2 end - specify "should translate values correctly" do + it "should translate values correctly" do @d << {:name => 'abc', :value => 456} @d << {:name => 'def', :value => 789} @d.filter('value > 500').update(:date_created => Sequel.lit("to_timestamp('2009-09-09', 'YYYY-MM-DD')")) - @d[:name => 'def'][:date_created].strftime('%F').should == '2009-09-09' + @d[:name => 'def'][:date_created].strftime('%F').must_equal '2009-09-09' end - specify "should delete records correctly" do + it "should delete records correctly" do @d << {:name => 'abc', :value => 123} @d << {:name => 'abc', :value => 456} @d << {:name => 'def', :value => 789} @d.filter(:name => 'abc').delete - @d.count.should == 1 - @d.first[:name].should == 'def' + @d.count.must_equal 1 + @d.first[:name].must_equal 'def' end - specify "should be able to literalize booleans" do - proc {@d.literal(true)}.should_not raise_error - proc {@d.literal(false)}.should_not raise_error + it "should be able to literalize booleans" do + @d.literal(true) + @d.literal(false) end - specify "should support transactions" do + it "should support transactions" do DB.transaction do @d << {:name => 'abc', :value => 1} end - @d.count.should == 1 + @d.count.must_equal 1 end - specify "should return correct result" do + it "should return correct result" do @d1 = DB[:books] @d1.delete @d1 << {:id => 1, :title => 'aaa', :category_id => 100} @d1 << {:id => 2, :title => 'bbb', :category_id => 100} @d1 << {:id => 3, :title => 'ccc', :category_id => 101} @@ -261,55 +261,53 @@ @d2 = DB[:categories] @d2.delete @d2 << {:id => 100, :cat_name => 'ruby'} @d2 << {:id => 101, :cat_name => 'rails'} - @d1.join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).order(:books__id).to_a.should == [ + @d1.join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).order(:books__id).to_a.must_equal [ {:id => 1, :title => 'aaa', :cat_name => 'ruby'}, {:id => 2, :title => 'bbb', :cat_name => 'ruby'}, {:id => 3, :title => 'ccc', :cat_name => 'rails'} ] - @d1.join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).order(:books__id).limit(2, 1).to_a.should == [ + @d1.join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).order(:books__id).limit(2, 1).to_a.must_equal [ {:id => 2, :title => 'bbb', :cat_name => 'ruby'}, {:id => 3, :title => 'ccc', :cat_name => 'rails'}, ] - @d1.left_outer_join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).order(:books__id).to_a.should == [ + @d1.left_outer_join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).order(:books__id).to_a.must_equal [ {:id => 1, :title => 'aaa', :cat_name => 'ruby'}, {:id => 2, :title => 'bbb', :cat_name => 'ruby'}, {:id => 3, :title => 'ccc', :cat_name => 'rails'}, {:id => 4, :title => 'ddd', :cat_name => nil} ] - @d1.left_outer_join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).reverse_order(:books__id).limit(2, 0).to_a.should == [ + @d1.left_outer_join(:categories, :id => :category_id).select(:books__id, :title, :cat_name).reverse_order(:books__id).limit(2, 0).to_a.must_equal [ {:id => 4, :title => 'ddd', :cat_name => nil}, {:id => 3, :title => 'ccc', :cat_name => 'rails'} ] end - specify "should allow columns to be renamed" do + it "should allow columns to be renamed" do @d1 = DB[:books] @d1.delete @d1 << {:id => 1, :title => 'aaa', :category_id => 100} @d1 << {:id => 2, :title => 'bbb', :category_id => 100} @d1 << {:id => 3, :title => 'bbb', :category_id => 100} - @d1.select(Sequel.as(:title, :name)).order_by(:id).to_a.should == [ + @d1.select(Sequel.as(:title, :name)).order_by(:id).to_a.must_equal [ { :name => 'aaa' }, { :name => 'bbb' }, { :name => 'bbb' }, ] - end - specify "nested queries should work" do - DB[:books].select(:title).group_by(:title).count.should == 2 + DB[:books].select(:title).group_by(:title).count.must_equal 2 end - specify "#for_update should use FOR UPDATE" do - DB[:books].for_update.sql.should == 'SELECT * FROM "BOOKS" FOR UPDATE' + it "#for_update should use FOR UPDATE" do + DB[:books].for_update.sql.must_equal 'SELECT * FROM "BOOKS" FOR UPDATE' end - specify "#lock_style should accept symbols" do - DB[:books].lock_style(:update).sql.should == 'SELECT * FROM "BOOKS" FOR UPDATE' + it "#lock_style should accept symbols" do + DB[:books].lock_style(:update).sql.must_equal 'SELECT * FROM "BOOKS" FOR UPDATE' end end