require 'spec_helper' describe SpudRole do before :each do @role = FactoryGirl.build(:spud_role) @full_access = SpudPermission.new('Test Full Access', 'admin.test.full_access') @partial_access = SpudPermission.new('Test Partial Access', 'admin.test.partial_access') Spud::Core.permissions += [@full_access, @partial_access] @role.permissions = [@partial_access] @role.save() end describe "permissions" do it "should return an array of SpudPermission objects" do @role.permissions.should be_an_instance_of(Array) @role.permissions.first.should be_an_instance_of(SpudPermission) end end describe "permissions=" do it "should update the SpudRolePermissions on the role" do original_count = @role.spud_role_permissions.length @role.permissions = [@full_access, @partial_access] @role.save @role.spud_role_permissions.length.should be > original_count end end describe "permission_tags" do it "should return an array of Strings" do @role.permission_tags.should be_an_instance_of(Array) @role.permission_tags.first.should be_an_instance_of(String) end end describe "permission_tags=" do it "should update the SpudRolePermissions on the role" do original_count = @role.spud_role_permissions.length @role.permission_tags = ['admin.test.full_access', 'admin.test.partial_access'] @role.save @role.spud_role_permissions.length.should be > original_count end end end