mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
Use RSpec's described_class feature to specify the subject
Removes code duplication and makes it easier to rename policies.
This commit is contained in:
parent
2214acf661
commit
2d36e93871
3 changed files with 5 additions and 5 deletions
|
@ -501,7 +501,7 @@ Then put your policy specs in `spec/policies`, and make them look somewhat like
|
|||
|
||||
``` ruby
|
||||
describe PostPolicy do
|
||||
subject { PostPolicy }
|
||||
subject { described_class }
|
||||
|
||||
permissions :update? do
|
||||
it "denies access if post is published" do
|
||||
|
|
|
@ -4,7 +4,7 @@ describe <%= class_name %>Policy do
|
|||
|
||||
let(:user) { User.new }
|
||||
|
||||
subject { <%= class_name %>Policy }
|
||||
subject { described_class }
|
||||
|
||||
permissions ".scope" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
|
|
|
@ -4,7 +4,7 @@ describe PostPolicy do
|
|||
let(:user) { double }
|
||||
let(:own_post) { double(user: user) }
|
||||
let(:other_post) { double(user: double) }
|
||||
subject { PostPolicy }
|
||||
subject { described_class }
|
||||
|
||||
permissions :update?, :show? do
|
||||
it "is successful when all permissions match" do
|
||||
|
|
Loading…
Reference in a new issue