spec/unit/grantee_spec.rb in cancannible-1.0.1 vs spec/unit/grantee_spec.rb in cancannible-2.0.0

- old
+ new

@@ -2,11 +2,10 @@ describe Cancannible::Grantee do let(:grantee_class) { Member } context "without permissions inheritance" do - describe "##inheritable_permissions" do subject { grantee_class.inheritable_permissions } it { should be_empty } end @@ -56,35 +55,10 @@ it { should be_truthy } end end end - context "with a nil resource" do - let!(:resource) { nil } - describe "#can? -> nil" do - subject { grantee.can?(:read, nil) } - context "when permission is not set" do - it { should be_falsey } - end - context "when permission is set" do - before { grantee.can(:read, resource) } - it { should be_truthy } - end - end - describe "#can? -> ''" do - subject { grantee.can?(:read, '') } - context "when permission is not set" do - it { should be_falsey } - end - context "when permission is set" do - before { grantee.can(:read, resource) } - it { should be_falsey } - end - end - end - - context "with a resource class" do let!(:resource) { Widget } describe "#can?" do subject { grantee.can?(:read, resource) } @@ -119,38 +93,35 @@ end context "with a non-existent model" do describe "instance" do let!(:obsolete_permission) {grantee.permissions.create!(asserted: true, ability: 'manage', resource_type: 'Bogative', resource_id: 33) } - it "should not error on load" do - expect { grantee.abilities }.to_not raise_error + it "raises CanCan::Error" do + expect { grantee.abilities }.to raise_error(CanCan::Error) end end describe "class" do let!(:obsolete_permission) {grantee.permissions.create!(asserted: true, ability: 'manage', resource_type: 'Bogative') } - it "should not error on load" do - grantee.abilities - expect { grantee.abilities }.to_not raise_error + it "raises CanCan::Error" do + expect { grantee.abilities }.to raise_error(CanCan::Error) end end end context "with an invalid model" do class SuperBogative < ActiveRecord::Base end context "instance" do - let!(:obsolete_permission) { grantee.permissions.create!(asserted: true, ability: 'manage', resource_type: 'SuperBogative', resource_id: 33) } - it "should not error on load" do + let!(:invalid_permission) { grantee.permissions.create!(asserted: true, ability: 'manage', resource_type: 'SuperBogative', resource_id: 33) } + it "does not error on load" do expect { grantee.abilities }.to_not raise_error end end context "class" do - let!(:obsolete_permission) { grantee.permissions.create!(asserted: true, ability: 'manage', resource_type: 'SuperBogative') } - it "should not error on load" do + let!(:invalid_permission) { grantee.permissions.create!(asserted: true, ability: 'manage', resource_type: 'SuperBogative') } + it "does not error on load" do expect { grantee.abilities }.to_not raise_error end end end - end - end \ No newline at end of file