spec/unit/chef/sugar/data_bag_spec.rb in chef-sugar-1.3.0 vs spec/unit/chef/sugar/data_bag_spec.rb in chef-sugar-2.0.0
- old
+ new
@@ -1,22 +1,22 @@
require 'spec_helper'
describe Chef::Sugar::DataBag do
describe '#encrypted_data_bag_item' do
- before { Chef::EncryptedDataBagItem.stub(:load) }
+ before { allow(Chef::EncryptedDataBagItem).to receive(:load) }
it 'loads the encrypted data bag item' do
expect(Chef::EncryptedDataBagItem).to receive(:load)
.with('accounts', 'github', 'secret_key')
described_class.encrypted_data_bag_item('accounts', 'github', 'secret_key')
end
context 'when Chef::Config is set' do
it 'loads the secret key from the Chef::Config' do
- Chef::Config.stub(:[]).with(:encrypted_data_bag_secret).and_return('/data/path')
- File.stub(:read).with('/data/path').and_return('B@c0n')
+ allow(Chef::Config).to receive(:[]).with(:encrypted_data_bag_secret).and_return('/data/path')
+ allow(File).to receive(:read).with('/data/path').and_return('B@c0n')
expect(Chef::EncryptedDataBagItem).to receive(:load)
.with('accounts', 'github', 'B@c0n')
described_class.encrypted_data_bag_item('accounts', 'github')
@@ -35,11 +35,11 @@
describe '#encrypted_data_bag_item_for_environment' do
let(:node) { double(:node, chef_environment: 'production') }
context 'when the environment exists' do
it 'loads the data from the environment' do
- Chef::EncryptedDataBagItem.stub(:load).and_return(
+ allow(Chef::EncryptedDataBagItem).to receive(:load).and_return(
'production' => {
'username' => 'sethvargo',
'password' => 'bacon',
}
)
@@ -51,10 +51,10 @@
end
end
context 'when the environment does not exist' do
it 'loads the data from the default bucket' do
- Chef::EncryptedDataBagItem.stub(:load).and_return(
+ allow(Chef::EncryptedDataBagItem).to receive(:load).and_return(
'staging' => {
'username' => 'sethvargo',
'password' => 'bacon',
},
'default' => {