# Copyright (c) 2014 Perforce Software, Inc. All rights reserved. require 'rspec' require 'helix_web_services_client' require_relative './test_config' RSpec.describe 'HelixWebServicesClient streams' do rand_str = (0...8).map { (65 + rand(26)).chr }.join stream_name = "main-#{rand_str}" stream_path = "//stream-test/#{stream_name}" stream_def = { 'Stream' => stream_path, 'Name' => stream_name, 'Description' => "Test stream #{stream_name}", 'Type' => 'mainline', 'Parent' => 'none', 'Paths' => ['share ...'], 'Owner' => 'jdoe' } it 'should create a new stream - and return it via #streams' do client_as_jdoe do |c| c.create_stream(stream_def) streams = c.streams expect(streams.map(&:stream)).to include(stream_path) end end it 'should load a single stream created via #create_stream' do client_as_jdoe do |c| new_stream = c.stream(stream_path) expect(new_stream.description.strip).to eq(stream_def['Description']) expect(new_stream.name).to eq(stream_def['Name']) expect(new_stream.type).to eq(stream_def['Type']) end end it 'should be able to update the stream description' do client_as_jdoe do |c| c.update_stream({ 'Stream' => stream_path, 'Description' => 'updated' }) loaded = c.stream(stream_path) expect(loaded.description).to include('updated') end end it "'should be able to delete a stream created via #create_stream'" do client_as_jdoe do |c| c.delete_stream(stream_path) streams = c.streams expect(streams.map(&:stream)).to_not include(stream_path) end end end