mirror of
https://github.com/Fishwaldo/role_model.git
synced 2025-03-15 19:42:43 +00:00
spec supported usage of -= on .roles
This commit is contained in:
parent
322fb3baf9
commit
3fe3a6d535
1 changed files with 39 additions and 0 deletions
|
@ -225,7 +225,46 @@ describe RoleModel do
|
|||
subject.should have(0).roles
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#-=" do
|
||||
subject { model_class.new }
|
||||
|
||||
context "with roles :foo and :bar already assigned" do
|
||||
before(:each) do
|
||||
subject.roles = [:foo, :bar]
|
||||
end
|
||||
|
||||
it "should delete a existing role given as a symbol" do
|
||||
subject.roles -= [:foo]
|
||||
subject.roles.should_not include(:foo)
|
||||
subject.should have(1).roles
|
||||
end
|
||||
|
||||
it "should delete a existing role given as a string" do
|
||||
subject.roles -= ['foo']
|
||||
subject.roles.should_not include(:foo)
|
||||
subject.should have(1).roles
|
||||
end
|
||||
|
||||
it "should not change anything if a non existing role is given" do
|
||||
subject.roles -= [:third]
|
||||
subject.roles.should include(:foo, :bar)
|
||||
subject.should have(2).roles
|
||||
end
|
||||
end
|
||||
|
||||
context "without roles assigned" do
|
||||
it "should have 0 roles if a role is given as a symbol" do
|
||||
subject.roles -= [:foo]
|
||||
subject.should have(0).roles
|
||||
end
|
||||
|
||||
it "should have 0 roles if a role is given as a string" do
|
||||
subject.roles -= ['foo']
|
||||
subject.should have(0).roles
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "query for an individual role" do
|
||||
|
|
Loading…
Add table
Reference in a new issue