Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated should_not raise_error(SpecificError). #689

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions spec/core/dataset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/core/schema_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/extensions/caching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions spec/extensions/hook_class_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/extensions/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/extensions/nested_attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -350,15 +350,15 @@ 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
al = @Album.load(:id=>10, :name=>'Al')
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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/model/associations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions spec/model/hooks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,15 +55,13 @@ 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

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
Expand Down Expand Up @@ -104,15 +102,13 @@ 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

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
Expand Down Expand Up @@ -208,15 +204,13 @@ 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

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
Expand Down