1
0
Fork 0
mirror of https://github.com/varvet/pundit.git synced 2022-11-09 12:30:11 -05:00
varvet--pundit/spec/policies/post_policy_spec.rb
nTraum 2d36e93871 Use RSpec's described_class feature to specify the subject
Removes code duplication and makes it easier to rename policies.
2014-10-14 00:32:54 +02:00

20 lines
513 B
Ruby

require "spec_helper"
describe PostPolicy do
let(:user) { double }
let(:own_post) { double(user: user) }
let(:other_post) { double(user: double) }
subject { described_class }
permissions :update?, :show? do
it "is successful when all permissions match" do
should permit(user, own_post)
end
it "fails when any permissions do not match" do
expect do
should permit(user, other_post)
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
end
end
end