# Copyright (c) 2014-2015 Perforce Software, Inc. All rights reserved. require 'rspec' require 'helix_web_services_client' require_relative './test_config' RSpec.describe "HelixWebServicesClient branches" do randstr = (0...8).map { (65 + rand(26)).chr }.join new_branch = { 'Branch' => "new_branch_#{randstr}", 'Description' => 'Something for the kids', 'View' => ['//depot/dev/kids/... //depot/main/kids/...'] } it 'should create a new branch - and return it via #branches' do client_as_jdoe do |c| c.create_branch(new_branch) branches = c.branches expect(branches.map(&:branch)).to include(new_branch['Branch']) end end it 'should load a single branch created via #create_branch' do client_as_jdoe do |c| new_branch = c.branch(new_branch['Branch']) expect(new_branch.description).to include(new_branch['Description']) expect(new_branch.view.length).to eq(1) expect(new_branch.view.first).to eq(new_branch['View'].first) end end it 'should be able to update the branch description' do client_as_jdoe do |c| to_update = c.branch(new_branch['Branch']) to_update.Description = 'updated' c.update_branch(to_update) loaded = c.branch(new_branch['Branch']) expect(loaded.description).to include('updated') end end it 'should be able to delete a branch created via #create_branch' do client_as_jdoe do |c| c.delete_branch(new_branch['Branch']) branches = c.branches expect(branches.map(&:branch)).to_not include(new_branch['Branch']) end end end