spec/unit/nodes_spec.rb in kitchen-nodes-0.3.2 vs spec/unit/nodes_spec.rb in kitchen-nodes-0.3.3

- old
+ new

@@ -83,10 +83,32 @@ allow_any_instance_of(Net::Ping::External).to receive(:ping) .and_return(true) allow(transport).to receive(:connection) .and_return(Kitchen::Transport::Base::Connection.new) end + + context 'cannot find an ip' do + let(:ifconfig_response) do + FakeFS.deactivate! + template = File.read('spec/unit/stubs/ifconfig.txt') + FakeFS.activate! + template.gsub!('', machine_ips[0]) + template.gsub!('', machine_ips[1]) + template.gsub!('', machine_ips[2]) + end + let(:transport) { Kitchen::Transport::Ssh.new } + + before do + allow_any_instance_of(Kitchen::Transport::Base::Connection) + .to receive(:node_execute).and_return(ifconfig_response) + end + + it 'fails' do + expect { subject.create_node }.to raise_error('Unable to retrieve IPs') + end + end + context 'platform is windows' do let(:transport) { Kitchen::Transport::Winrm.new } before do data = machine_ips.map { |ip| { stdout: "#{ip}\r\n" } } @@ -123,10 +145,11 @@ FakeFS.deactivate! template = File.read('spec/unit/stubs/ifconfig.txt') FakeFS.activate! template.gsub!('1.1.1.1', machine_ips[0]) template.gsub!('2.2.2.2', machine_ips[1]) + template.gsub!('3.3.3.3', machine_ips[2]) end let(:transport) { Kitchen::Transport::Ssh.new } before do allow_any_instance_of(Kitchen::Transport::Base::Connection) @@ -144,9 +167,10 @@ FakeFS.deactivate! template = File.read('spec/unit/stubs/ip.txt') FakeFS.activate! template.gsub!('1.1.1.1', machine_ips[0]) template.gsub!('2.2.2.2', machine_ips[1]) + template.gsub!('3.3.3.3', machine_ips[2]) end before do allow_any_instance_of(Kitchen::Transport::Base::Connection) .to receive(:node_execute).with('/sbin/ifconfig -a')