spec/unit/nodes_spec.rb in kitchen-nodes-0.3.4 vs spec/unit/nodes_spec.rb in kitchen-nodes-0.4.0

- old
+ new

@@ -11,11 +11,12 @@ let(:config) do { test_base_path: '/b', kitchen_root: '/r', run_list: 'cookbook:recipe', - attributes: { att_key: 'att_val' } + attributes: { att_key: 'att_val' }, + client_rb: { environment: 'my_env' } } end let(:instance) do double( 'instance', @@ -55,10 +56,16 @@ subject.create_node expect(node[:id]).to eq instance.name end + it 'sets the environment' do + subject.create_node + + expect(node[:chef_environment]).to eq config[:client_rb][:environment] + end + it 'sets the runlist' do subject.create_node expect(node[:run_list]).to eq config[:run_list] end @@ -71,9 +78,19 @@ it 'sets the ip address' do subject.create_node expect(node[:automatic][:ipaddress]).to eq state[:hostname] + end + + context 'no environment explicitly set' do + before { config.delete(:client_rb) } + + it 'sets the environment' do + subject.create_node + + expect(node[:chef_environment]).to eq '_default' + end end context 'instance is localhost' do let(:state) { { hostname: '127.0.0.1' } } let(:machine_ips) { ['192.168.1.1', '192.168.1.2', '192.168.1.3'] }