From 68a2661f03a46a9b508829337bf5a6035e2ad0a3 Mon Sep 17 00:00:00 2001 From: Jacob Zaval Date: Mon, 7 Mar 2022 17:59:07 -0800 Subject: [PATCH] update resource unit tests --- libraries/developer_account.rb | 6 +++--- spec/unit/resources/xcode_spec.rb | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/developer_account.rb b/libraries/developer_account.rb index 2323857..9cfeca2 100644 --- a/libraries/developer_account.rb +++ b/libraries/developer_account.rb @@ -9,7 +9,7 @@ module MacOS if download_url.empty? developer_id = validate_apple_id(apple_id_hash) @credentials = { - XCODE_INSTALL_USER: developer_id[:apple_id], + XCODE_INSTALL_USER: developer_id[:username], XCODE_INSTALL_PASSWORD: developer_id[:password], } authenticate_with_apple(@credentials) @@ -19,12 +19,12 @@ module MacOS def validate_apple_id(apple_id_hash) if apple_id_hash.values.any? { - apple_id: apple_id_hash[:username], + username: apple_id_hash[:username], password: apple_id_hash[:password], } elsif ENV['XCODE_INSTALL_USER'] && ENV['XCODE_INSTALL_PASSWORD'] { - apple_id: ENV['XCODE_INSTALL_USER'], + username: ENV['XCODE_INSTALL_USER'], password: ENV['XCODE_INSTALL_PASSWORD'], } else diff --git a/spec/unit/resources/xcode_spec.rb b/spec/unit/resources/xcode_spec.rb index 58f6747..7e33b10 100644 --- a/spec/unit/resources/xcode_spec.rb +++ b/spec/unit/resources/xcode_spec.rb @@ -4,10 +4,9 @@ describe 'xcode' do step_into :xcode platform 'mac_os_x' - default_attributes['macos']['apple_id']['user'] = 'developer@apple.com' - default_attributes['macos']['apple_id']['password'] = 'apple_id_password' - before(:each) do + allow_any_instance_of(MacOS::DeveloperAccount).to receive(:validate_apple_id) + .and_return({ username: 'user@example', password: 'placeholder' }) allow_any_instance_of(MacOS::DeveloperAccount).to receive(:authenticate_with_apple) .and_return(true) allow(MacOS::XCVersion).to receive(:available_versions)