# Copyright (c) 2014-2015 Perforce Software, Inc. All rights reserved. require 'rspec' require 'helix_web_services_client' require_relative './test_config' RSpec.describe 'HelixWebServicesClient projects' do my_project_id = 'My~20Project' context 'projects' do it 'should not fail when listing projects' do client_as_jdoe do |c| c.projects end end context 'HVE Projects' do it 'should list project ids when details are not specified' do client_as_jdoe do |c| c.add_setting('HVE_PROJECTS_PATH', '//depot/main') projects = c.projects expect(projects).to include(my_project_id) end end it 'should list project details when details are specified' do client_as_jdoe do |c| c.add_setting('HVE_PROJECTS_PATH', '//depot/main') projects = c.projects(details: true) my_project = projects.find{|p| p.id == my_project_id} expect(my_project).to_not be_nil expect(my_project.name).to eq('My Project') expect(my_project.server).to_not be_nil expect(my_project.hve_project['depotPath']).to eq('//depot/main/My Project') end end end end context 'project' do it 'should trigger a 404 when fetching a project by invalid id' do client_as_jdoe do |c| expect { c.project('invalid') }.to raise_error(Errors::ResourceNotFound) end end context 'HVE Projects' do it 'should fetch my project details' do client_as_jdoe do |c| c.add_setting('HVE_PROJECTS_PATH', '//depot/main') my_project = c.project(my_project_id) expect(my_project).to_not be_nil expect(my_project.id).to eq(my_project_id) expect(my_project.name).to eq('My Project') expect(my_project.server).to_not be_nil expect(my_project.hve_project['depotPath']).to eq('//depot/main/My Project') end end end end end