summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-03-11 20:05:08 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-03-20 14:38:05 -0700
commit9a65eb8552db53fdd0bd93c945e001905ad793e3 (patch)
tree5765c2c51cac1f804de07fee70c71e3edf5c1093 /spec
parenta6902ea47197a9f2600795a7d1d48713ea05dbd1 (diff)
downloadchef-9a65eb8552db53fdd0bd93c945e001905ad793e3.tar.gz
Refactor ps_credential for easier mocking
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/util/powershell/ps_credential_spec.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb
index a2d51246df..e043fd92ec 100644
--- a/spec/unit/util/powershell/ps_credential_spec.rb
+++ b/spec/unit/util/powershell/ps_credential_spec.rb
@@ -24,17 +24,14 @@ describe Chef::Util::Powershell::PSCredential do
@node = Chef::Node.new
end
- before (:example) do
- allow(Chef::ReservedNames::Win32::Crypto).to receive(:encrypt).and_return("encrypted")
- end
-
let (:username) { 'foo' }
let (:password) { 'password' }
-
+
context 'when username and password are provided' do
let(:ps_credential) { Chef::Util::Powershell::PSCredential.new(username, password)}
context 'when calling to_psobject' do
it 'should create the script to create a PSCredential when calling' do
+ allow(ps_credential).to receive(:encrypt).with(password).and_return('encrypted')
expect(ps_credential.to_psobject).to eq(
"New-Object System.Management.Automation.PSCredential('#{username}',('encrypted' | ConvertTo-SecureString))")
end