Skip to content

Commit d283c4a

Browse files
committed
spec: fix false positive due to too-broad of exception handling
define and expect a specific exception, and then fix the spec so it doesn't fail Change-Id: I4fafd4f416f906a2d11b6ae84602c7319a116b55 Reviewed-on: https://gerrit.instructure.com/89884 Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Jenkins Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
1 parent f6d8d67 commit d283c4a

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/dates_overridable.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module DatesOverridable
44
attr_writer :without_overrides
55
include DifferentiableAssignment
66

7+
class NotOverriddenError < RuntimeError; end
8+
79
def self.included(base)
810
base.has_many :assignment_overrides, :dependent => :destroy
911
base.has_many :active_assignment_overrides, -> { where(workflow_state: 'active') }, class_name: 'AssignmentOverride'
@@ -52,7 +54,7 @@ def multiple_due_dates?
5254
if overridden
5355
!!multiple_due_dates_apply_to?(overridden_for_user)
5456
else
55-
raise "#{self.class.name} has not been overridden"
57+
raise NotOverriddenError, "#{self.class.name} has not been overridden"
5658
end
5759
end
5860

spec/lib/dates_overridable_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422

423423
context "when the object hasn't been overridden" do
424424
it "raises an exception because it doesn't have any context" do
425-
expect { overridden.multiple_due_dates? }.to raise_exception
425+
expect { overridable.multiple_due_dates? }.to raise_exception(DatesOverridable::NotOverriddenError)
426426
end
427427
end
428428

0 commit comments

Comments
 (0)