Ad
  • Custom User Avatar

    This is a standard tree search kata, which has been done a lot of CW.

  • Custom User Avatar

    Needs sample tests.

  • Custom User Avatar

    No random tests.

  • Custom User Avatar

    Tests should use assert_equals.

  • Custom User Avatar

    Needs random tests

  • Custom User Avatar

    The tests should be augmented. The current tests don't seem to test (judging by accepted solutions) for the case when roles are not added implicitly to the role on which we call all_permissions, but only as sub-roles of other roles. E.g.:

    can_edit = Permission.new 'Edit'
    editors = Role.new 'Editor'
    editors.permissions << can_edit
    
    can_create = Permissions.new 'Create'
    creators = Role.new 'Creator'
    creators.permissions << can_create
    creators.roles << editors
    
    admins = Role.new 'Admin'
    admins.roles << creators # Note that only creators are added explicitly, by editors is the sub-role of creators
    
    Test.expect(admins.all_permissions.includes?(can_edit)) # Should include 'Edit' since 'Editors' are included in 'Creators'
    

    Also, should test for circular references announces in the kata description ("A role can reference itself"). E.g., extending my example from above:

    can_edit = Permission.new 'Edit'
    editors = Role.new 'Editor'
    editors.permissions << can_edit
    
    can_create = Permissions.new 'Create'
    creators = Role.new 'Creator'
    creators.permissions << can_create
    creators.roles << editors
    
    admins = Role.new 'Admin'
    admins.roles << creators
    admins.roles << admins # circular reference!
    
    Test.assert_equals( admins.all_permissions.map(&:name).sort, ['Create','Edit'] ) # Still should include the two permissions
    
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution