私は RSpec を学んでいますが、共有サブジェクトを理解するのに少し問題があり、それが新しい期待構文でどのように機能するかを理解しています。
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 }
私はこれについて間違っていますか?