spec/unit/chef/sugar/node_spec.rb in chef-sugar-2.2.0 vs spec/unit/chef/sugar/node_spec.rb in chef-sugar-2.3.0
- old
+ new
@@ -2,18 +2,18 @@
describe Chef::Node do
describe '#in?' do
it 'returns true when the node is in the environment' do
allow(subject).to receive(:chef_environment).and_return('production')
- expect(subject.in?('production')).to be_truthy
- expect(subject.in?(/production$/)).to be_truthy
+ expect(subject.in?('production')).to be true
+ expect(subject.in?(/production$/)).to be true
end
it 'returns false when the node is not in the environment' do
allow(subject).to receive(:chef_environment).and_return('staging')
- expect(subject.in?('production')).to be_falsey
- expect(subject.in?(/production$/)).to be_falsey
+ expect(subject.in?('production')).to be false
+ expect(subject.in?(/production$/)).to be false
end
end
describe '#deep_fetch' do
let(:node) { described_class.new }
@@ -94,9 +94,29 @@
end
expect(node.override).to eq({
'apache2' => {
'config' => { 'root' => '/var/www' }
+ }
+ })
+ end
+
+ it 'can access attributes within itself' do
+ node.instance_eval do
+ namespace 'apache2' do
+ namespace 'config' do
+ root '/var/www'
+ ssl File.join(root, 'ssl')
+ end
+ end
+ end
+
+ expect(node.default).to eq({
+ 'apache2' => {
+ 'config' => {
+ 'root' => '/var/www',
+ 'ssl' => '/var/www/ssl',
+ }
}
})
end
end