diff --git a/CHANGELOG.md b/CHANGELOG.md index 84b1a6a4..2d2195d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -Nothing. +- Policy generator uses `NoMethodError` to indicate `#resolve` is not implemented (#776) ## 2.3.1 (2023-07-17) diff --git a/lib/generators/pundit/install/templates/application_policy.rb b/lib/generators/pundit/install/templates/application_policy.rb index e000cba5..be644fe3 100644 --- a/lib/generators/pundit/install/templates/application_policy.rb +++ b/lib/generators/pundit/install/templates/application_policy.rb @@ -43,7 +43,7 @@ def initialize(user, scope) end def resolve - raise NotImplementedError, "You must define #resolve in #{self.class}" + raise NoMethodError, "You must define #resolve in #{self.class}" end private diff --git a/spec/generators_spec.rb b/spec/generators_spec.rb index 5f158776..e157e391 100644 --- a/spec/generators_spec.rb +++ b/spec/generators_spec.rb @@ -35,7 +35,7 @@ describe "#resolve" do it "raises a descriptive error" do scope = WidgetPolicy::Scope.new(double("User"), double("User.all")) - expect { scope.resolve }.to raise_error(NotImplementedError, /WidgetPolicy::Scope/) + expect { scope.resolve }.to raise_error(NoMethodError, /WidgetPolicy::Scope/) end end end