2
我在学习RSpec,并且在理解共享主题方面有点麻烦,以及它如何与新期望语法一起工作。使用新的Rspec语法在CanCan中测试功能
我跟着tutorial from the cancan wiki,但我不知道如何测试用户不应该能够执行相同语法的操作。
user_spec.rb:
require 'spec_helper'
require "cancan/matchers"
describe User do
describe 'abilities' do
let(:user) { FactoryGirl.create(:user) }
let(:ability) { FactoryGirl.create(:user) }
subject(:ability) { Ability.new(user) }
it { should be_able_to :read, User.new }
# clunky expectation
it 'should not be able to destroy others' do
expect(ability).not_to be_able_to(:destroy, User.new)
end
end
end
我想要做的是写像
it { should not be_able_to :delete, User.new }
我要对这个错误的期待?