diff --git a/lib/pundit/policy_finder.rb b/lib/pundit/policy_finder.rb index adb3b07..a3c4d42 100644 --- a/lib/pundit/policy_finder.rb +++ b/lib/pundit/policy_finder.rb @@ -21,12 +21,12 @@ module Pundit end def scope! - raise NotDefinedError, "unable to find policy scope of blank object `#{object.inspect}`" if object.blank? + raise NotDefinedError, "unable to find policy scope of nil" if object.nil? scope or raise NotDefinedError, "unable to find scope `#{find}::Scope` for `#{object.inspect}`" end def policy! - raise NotDefinedError, "unable to find policy of blank object `#{object.inspect}`" if object.blank? + raise NotDefinedError, "unable to find policy of nil" if object.nil? policy or raise NotDefinedError, "unable to find policy `#{find}` for `#{object.inspect}`" end diff --git a/spec/pundit_spec.rb b/spec/pundit_spec.rb index c74d126..d751b33 100644 --- a/spec/pundit_spec.rb +++ b/spec/pundit_spec.rb @@ -64,7 +64,7 @@ describe Pundit do end it "throws an exception if the given policy scope is nil" do - expect { Pundit.policy_scope!(user, nil) }.to raise_error(Pundit::NotDefinedError, "unable to find policy scope of blank object `nil`") + expect { Pundit.policy_scope!(user, nil) }.to raise_error(Pundit::NotDefinedError, "unable to find policy scope of nil") end end @@ -188,7 +188,7 @@ describe Pundit do end it "throws an exception if the given policy is nil" do - expect { Pundit.policy!(user, nil) }.to raise_error(Pundit::NotDefinedError, "unable to find policy of blank object `nil`") + expect { Pundit.policy!(user, nil) }.to raise_error(Pundit::NotDefinedError, "unable to find policy of nil") end end