diff --git a/Rakefile b/Rakefile index 7da7cd93fb..bf2878b98f 100644 --- a/Rakefile +++ b/Rakefile @@ -160,7 +160,14 @@ begin t end - task :default => [:spec] + task :default do + STDERR.puts """ + Running core, model, bin, plugin and core_ext specs. + Run other specs manually with rake {spec_integration,spec_sqlite,spec_postgres,spec_mysql}. + """ + [:spec, :spec_bin, :spec_plugin, :spec_core_ext].each {|t| Rake::Task[t].invoke } + end + spec_with_cov.call("spec", Dir["spec/{core,model}/*_spec.rb"], "Run core and model specs"){|t| t.rcov_opts.concat(%w'--exclude "lib/sequel/(adapters/([a-ln-z]|m[a-np-z])|extensions/core_extensions)"')} spec.call("spec_bin", ["spec/bin_spec.rb"], "Run bin/sequel specs") spec.call("spec_core", Dir["spec/core/*_spec.rb"], "Run core specs") diff --git a/spec/core/dataset_spec.rb b/spec/core/dataset_spec.rb index 96a92423ed..3d192844ce 100644 --- a/spec/core/dataset_spec.rb +++ b/spec/core/dataset_spec.rb @@ -1609,10 +1609,10 @@ def d.to_s; "adsf" end specify "should raise an error if an invalid limit or offset is used" do proc{@dataset.limit(-1)}.should raise_error(Sequel::Error) proc{@dataset.limit(0)}.should raise_error(Sequel::Error) - proc{@dataset.limit(1)}.should_not raise_error(Sequel::Error) + proc{@dataset.limit(1)}.should_not raise_error proc{@dataset.limit(1, -1)}.should raise_error(Sequel::Error) - proc{@dataset.limit(1, 0)}.should_not raise_error(Sequel::Error) - proc{@dataset.limit(1, 1)}.should_not raise_error(Sequel::Error) + proc{@dataset.limit(1, 0)}.should_not raise_error + proc{@dataset.limit(1, 1)}.should_not raise_error end end diff --git a/spec/core/schema_spec.rb b/spec/core/schema_spec.rb index f67b738bc0..516f22a7c5 100644 --- a/spec/core/schema_spec.rb +++ b/spec/core/schema_spec.rb @@ -446,7 +446,7 @@ def @db.supports_named_column_constraints?; false end meta_def(@db, :execute_ddl){|*a| raise Sequel::DatabaseError if /blah/.match(a.first); super(*a)} lambda{@db.create_table(:cats){Integer :id; index :blah; index :id}}.should raise_error(Sequel::DatabaseError) @db.sqls.should == ['CREATE TABLE cats (id integer)'] - lambda{@db.create_table(:cats, :ignore_index_errors=>true){Integer :id; index :blah; index :id}}.should_not raise_error(Sequel::DatabaseError) + lambda{@db.create_table(:cats, :ignore_index_errors=>true){Integer :id; index :blah; index :id}}.should_not raise_error @db.sqls.should == ['CREATE TABLE cats (id integer)', 'CREATE INDEX cats_id_index ON cats (id)'] end @@ -965,7 +965,7 @@ def @db.supports_named_column_constraints?; false end specify "should ignore errors if the database raises an error on an add_index call and the :ignore_errors option is used" do meta_def(@db, :execute_ddl){|*a| raise Sequel::DatabaseError} lambda{@db.add_index(:cats, :id)}.should raise_error(Sequel::DatabaseError) - lambda{@db.add_index(:cats, :id, :ignore_errors=>true)}.should_not raise_error(Sequel::DatabaseError) + lambda{@db.add_index(:cats, :id, :ignore_errors=>true)}.should_not raise_error @db.sqls.should == [] end diff --git a/spec/extensions/caching_spec.rb b/spec/extensions/caching_spec.rb index d1ce40648a..6bf1362a3e 100644 --- a/spec/extensions/caching_spec.rb +++ b/spec/extensions/caching_spec.rb @@ -125,12 +125,12 @@ def self.name; 'SubItem' end m = @c.new proc {m.cache_key}.should raise_error(Sequel::Error) m.values[:id] = 1 - proc {m.cache_key}.should_not raise_error(Sequel::Error) + proc {m.cache_key}.should_not raise_error m = @c2.new proc {m.cache_key}.should raise_error(Sequel::Error) m.values[:id] = 1 - proc {m.cache_key}.should_not raise_error(Sequel::Error) + proc {m.cache_key}.should_not raise_error end it "should not raise error if trying to save a new record" do diff --git a/spec/extensions/hook_class_methods_spec.rb b/spec/extensions/hook_class_methods_spec.rb index 45de3bf8ce..a59892ffba 100644 --- a/spec/extensions/hook_class_methods_spec.rb +++ b/spec/extensions/hook_class_methods_spec.rb @@ -184,7 +184,6 @@ specify ".create should cancel the save and raise an error if before_create returns false and raise_on_save_failure is true" do @c.before_create{false} - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) proc{@c.create(:x => 2)}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -215,7 +214,6 @@ specify "#save should cancel the save and raise an error if before_update returns false and raise_on_save_failure is true" do @c.before_update{false} - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -254,7 +252,6 @@ specify "#save should cancel the save and raise an error if before_save returns false and raise_on_save_failure is true" do @c.before_save{false} - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -339,7 +336,6 @@ def self.validate(o) specify "#save should cancel the save and raise an error if before_validation returns false and raise_on_save_failure is true" do @c.before_validation{false} - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end diff --git a/spec/extensions/migration_spec.rb b/spec/extensions/migration_spec.rb index f07745be37..cf6350edce 100644 --- a/spec/extensions/migration_spec.rb +++ b/spec/extensions/migration_spec.rb @@ -194,19 +194,19 @@ def alter_table(*args, &block) specify "should raise in the down direction if migration uses unsupported method" do m = Sequel.migration{change{run 'SQL'}} - proc{m.apply(@db, :up)}.should_not raise_error(Sequel::Error) + proc{m.apply(@db, :up)}.should_not raise_error proc{m.apply(@db, :down)}.should raise_error(Sequel::Error) end specify "should raise in the down direction if migration uses add_primary_key with an array" do m = Sequel.migration{change{alter_table(:a){add_primary_key [:b]}}} - proc{m.apply(@db, :up)}.should_not raise_error(Sequel::Error) + proc{m.apply(@db, :up)}.should_not raise_error proc{m.apply(@db, :down)}.should raise_error(Sequel::Error) end specify "should raise in the down direction if migration uses add_foreign_key with an array" do m = Sequel.migration{change{alter_table(:a){add_foreign_key [:b]}}} - proc{m.apply(@db, :up)}.should_not raise_error(Sequel::Error) + proc{m.apply(@db, :up)}.should_not raise_error proc{m.apply(@db, :down)}.should raise_error(Sequel::Error) end end @@ -263,7 +263,7 @@ def table_exists?(name) end specify "should not raise and error if there is a missing integer migration version and allow_missing_migration_files is true" do - Sequel::Migrator.run(@db, "spec/files/missing_integer_migrations", :allow_missing_migration_files => true).should_not raise_error(Sequel::Migrator::Error) + proc{Sequel::Migrator.run(@db, "spec/files/missing_integer_migrations", :allow_missing_migration_files => true)}.should_not raise_error end specify "should raise and error if there is a duplicate integer migration version" do @@ -622,7 +622,7 @@ def create_table(name, *args, &block) @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb 1273253853_3_create_users.rb' @dir = 'spec/files/missing_timestamped_migrations' - proc{@m.run(@db, @dir, :allow_missing_migration_files => true)}.should_not raise_error(Sequel::Migrator::Error) + proc{@m.run(@db, @dir, :allow_missing_migration_files => true)}.should_not raise_error [:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true} @db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb 1273253853_3_create_users.rb' end diff --git a/spec/extensions/nested_attributes_spec.rb b/spec/extensions/nested_attributes_spec.rb index 2f314d0a52..dff287608e 100644 --- a/spec/extensions/nested_attributes_spec.rb +++ b/spec/extensions/nested_attributes_spec.rb @@ -340,7 +340,7 @@ def before_create # Have to define the CPK somehow. @Album.nested_attributes :artist proc{a.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})}.should raise_error(Sequel::Error) @Album.nested_attributes :artist, :destroy=>true - proc{a.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})}.should_not raise_error(Sequel::Error) + proc{a.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})}.should_not raise_error end it "should only allow removing associated objects if :remove option is used in the nested_attributes call" do @@ -350,7 +350,7 @@ def before_create # Have to define the CPK somehow. @Album.nested_attributes :artist proc{a.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})}.should raise_error(Sequel::Error) @Album.nested_attributes :artist, :remove=>true - proc{a.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})}.should_not raise_error(Sequel::Error) + proc{a.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})}.should_not raise_error end it "should raise an Error if a primary key is given in a nested attribute hash, but no matching associated object exists" do @@ -358,7 +358,7 @@ def before_create # Have to define the CPK somehow. ar = @Artist.load(:id=>20, :name=>'Ar') ar.associations[:albums] = [al] proc{ar.set(:albums_attributes=>[{:id=>30, :_delete=>'t'}])}.should raise_error(Sequel::Error) - proc{ar.set(:albums_attributes=>[{:id=>10, :_delete=>'t'}])}.should_not raise_error(Sequel::Error) + proc{ar.set(:albums_attributes=>[{:id=>10, :_delete=>'t'}])}.should_not raise_error end it "should not raise an Error if an unmatched primary key is given, if the :strict=>false option is used" do @@ -388,7 +388,7 @@ def before_create # Have to define the CPK somehow. co = @Concert.load(:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl') ar.associations[:concerts] = [co] proc{ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-04', :_delete=>'t'}])}.should raise_error(Sequel::Error) - proc{ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :_delete=>'t'}])}.should_not raise_error(Sequel::Error) + proc{ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :_delete=>'t'}])}.should_not raise_error end it "should not raise an Error if an unmatched composite primary key is given, if the :strict=>false option is used" do diff --git a/spec/model/associations_spec.rb b/spec/model/associations_spec.rb index 582679ab58..7f23ffd4c4 100644 --- a/spec/model/associations_spec.rb +++ b/spec/model/associations_spec.rb @@ -134,8 +134,8 @@ class ::ParParent < Sequel::Model; end it "should allow cloning of one_to_many to one_to_one associations and vice-versa" do c = Class.new(Sequel::Model(:c)) c.one_to_one :c - proc{c.one_to_many :cs, :clone=>:c}.should_not raise_error(Sequel::Error) - proc{c.one_to_one :c2, :clone=>:cs}.should_not raise_error(Sequel::Error) + proc{c.one_to_many :cs, :clone=>:c}.should_not raise_error + proc{c.one_to_one :c2, :clone=>:cs}.should_not raise_error end it "should clear associations cache when refreshing object manually" do diff --git a/spec/model/hooks_spec.rb b/spec/model/hooks_spec.rb index e1e2dd4fc5..f50fd4bc5f 100644 --- a/spec/model/hooks_spec.rb +++ b/spec/model/hooks_spec.rb @@ -24,7 +24,7 @@ def after_create @c.send(:define_method, :before_create){false} proc{@c.create(:x => 2)}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) + proc{@c.load(:id => 2233).save}.should_not raise_error end specify ".create should cancel the save and return nil if before_create returns false and raise_on_save_failure is false" do @@ -55,7 +55,6 @@ def after_update specify "#save should cancel the save and raise an error if before_update returns false and raise_on_save_failure is true" do @c.send(:define_method, :before_update){false} - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -63,7 +62,6 @@ def after_update specify "#save should cancel the save and raise an error if before_update returns false and raise_on_failure option is true" do @c.send(:define_method, :before_update){false} @c.raise_on_save_failure = false - proc{@c.load(:id => 2233).save(:raise_on_failure => true)}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save(:raise_on_failure => true)}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -104,7 +102,6 @@ def after_save specify "#save should cancel the save and raise an error if before_save returns false and raise_on_save_failure is true" do @c.send(:define_method, :before_save){false} - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -112,7 +109,6 @@ def after_save specify "#save should cancel the save and raise an error if before_save returns false and raise_on_failure option is true" do @c.send(:define_method, :before_save){false} @c.raise_on_save_failure = false - proc{@c.load(:id => 2233).save(:raise_on_failure => true)}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save(:raise_on_failure => true)}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -208,7 +204,6 @@ def validate specify "#save should cancel the save and raise an error if before_validation returns false and raise_on_save_failure is true" do @c.send(:define_method, :before_validation){false} - proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end @@ -216,7 +211,6 @@ def validate specify "#save should cancel the save and raise an error if before_validation returns false and raise_on_failure option is true" do @c.send(:define_method, :before_validation){false} @c.raise_on_save_failure = false - proc{@c.load(:id => 2233).save(:raise_on_failure => true)}.should_not raise_error(Sequel::ValidationFailed) proc{@c.load(:id => 2233).save(:raise_on_failure => true)}.should raise_error(Sequel::BeforeHookFailed) DB.sqls.should == [] end