1
0
Fork 0
mirror of https://github.com/varvet/pundit.git synced 2022-11-09 12:30:11 -05:00

Use #inspect over #to_s, closes #200

This commit is contained in:
Jonas Nicklas 2015-03-27 10:22:30 +01:00
parent 2eed1d9136
commit 66ba305eb8
3 changed files with 4 additions and 2 deletions

View file

@ -15,7 +15,7 @@ module Pundit
@record = options[:record]
@policy = options[:policy]
message = options.fetch(:message) { "not allowed to #{query} this #{record}" }
message = options.fetch(:message) { "not allowed to #{query} this #{record.inspect}" }
super(message)
end

View file

@ -20,7 +20,7 @@ describe Pundit do
end
it "raises an error with a query and action" do
expect { Pundit.authorize(user, post, :destroy?) }.to raise_error(Pundit::NotAuthorizedError) do |error|
expect { Pundit.authorize(user, post, :destroy?) }.to raise_error(Pundit::NotAuthorizedError, "not allowed to destroy? this #<Post>") do |error|
expect(error.query).to eq :destroy?
expect(error.record).to eq post
expect(error.policy).to eq Pundit.policy(user, post)

View file

@ -42,6 +42,8 @@ class Post < Struct.new(:user)
def self.published
:published
end
def to_s; "Post"; end
def inspect; "#<Post>"; end
end
class CommentPolicy < Struct.new(:user, :comment); end