# Copyright (c) 2014 Perforce Software, Inc. All rights reserved. require_relative './test_config' require 'helix_web_services_client' RSpec.describe 'HelixWebServicesClient groups' do randstr = (0...8).map { (65 + rand(26)).chr }.join group_id = "test_#{randstr}" new_group = { 'Group' => group_id, 'Users' => ['jdoe'] } context '#create_group' do it 'should create a new group - and return it via #groups' do client_as_super do |c| c.create_group(new_group) groups = c.groups expect(groups.map(&:group)).to include(group_id) end end end context '#group' do it 'should load a single group created via #create_group' do client_as_jdoe do |c| jarjar = c.group(group_id) expect(jarjar.users).to include('jdoe') end end end context '#update_group' do it 'should be able to add a group user' do client_as_super do |c| group = c.group(group_id) group.users << 'super' c.update_group(group) loaded = c.group(group_id) expect(loaded.users).to include('super') end end end context '#delete_group' do it 'should be able to delete a group created via #create_group' do client_as_super do |c| c.delete_group(group_id) groups = c.groups expect(groups.map(&:group)).to_not include(group_id) end end end end