spec/sequel_model/hooks_spec.rb in sequel-2.8.0 vs spec/sequel_model/hooks_spec.rb in sequel-2.9.0

- old
+ new

@@ -211,11 +211,12 @@ ] end 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.create(:x => 2)}.should raise_error(Sequel::Error) + proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) + proc{@c.create(:x => 2)}.should raise_error(Sequel::BeforeHookFailed) MODEL_DB.sqls.should == [] end specify ".create should cancel the save and return nil if before_create returns false and raise_on_save_failure is false" do @c.before_create{false} @@ -246,11 +247,12 @@ ] end 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 raise_error(Sequel::Error) + proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) + proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) MODEL_DB.sqls.should == [] end specify "#save should cancel the save and return nil if before_update returns false and raise_on_save_failure is false" do @c.before_update{false} @@ -293,11 +295,12 @@ ] end 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 raise_error(Sequel::Error) + proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) + proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) MODEL_DB.sqls.should == [] end specify "#save should cancel the save and return nil if before_save returns false and raise_on_save_failure is false" do @c.before_save{false} @@ -332,11 +335,11 @@ ] end specify "#destroy should cancel the destroy and raise an error if before_destroy returns false and raise_on_save_failure is true" do @c.before_destroy{false} - proc{@c.load(:id => 2233).destroy}.should raise_error(Sequel::Error) + proc{@c.load(:id => 2233).destroy}.should raise_error(Sequel::BeforeHookFailed) MODEL_DB.sqls.should == [] end specify "#destroy should cancel the destroy and return nil if before_destroy returns false and raise_on_save_failure is false" do @c.before_destroy{false} @@ -391,10 +394,11 @@ MODEL_DB.sqls.should == ['BLAH before', 'BLAH after'] end 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 raise_error(Sequel::Error) + proc{@c.load(:id => 2233).save}.should_not raise_error(Sequel::ValidationFailed) + proc{@c.load(:id => 2233).save}.should raise_error(Sequel::BeforeHookFailed) MODEL_DB.sqls.should == [] end specify "#save should cancel the save and return nil if before_validation returns false and raise_on_save_failure is false" do @c.before_validation{false}