我正在尝试将以下规范转换为新的期望语法,有人可以帮忙吗?
describe PostPolicy do
subject { PostPolicy }
permissions :create? do
it "denies access if post is published" do
should_not permit(User.new(:admin => false), Post.new(:published => true))
end
it "grants access if post is published and user is an admin" do
should permit(User.new(:admin => true), Post.new(:published => true))
end
it "grants access if post is unpublished" do
should permit(User.new(:admin => false), Post.new(:published => false))
end
end
end
我试过了,但它没有用,因为permit()
返回了一个匹配器—— RSpec::Matchers::DSL::Matcher
:
specify { expect(permit(@user, @post)).to be_true }