spec/consolr_spec.rb in consolr-1.0.2 vs spec/consolr_spec.rb in consolr-1.1.0

- old
+ new

@@ -24,9 +24,43 @@ it 'fails if multiple hosts are found' do expect { @console.start({:hostname => 'hostname-with-multiple-assets.dc.net'}) }.to raise_error(SystemExit, /Found \d+ assets/) end + it 'loads ipmitool as the default runner' do + expect_any_instance_of(Consolr::Runners::Ipmitool).to receive(:initialize) + @console.start({:tag => 'safe-allocated-tag', :on => true}) + end + + it 'prints an error when passed an unknown runner' do + expect { + @console.start({:tag => 'safe-allocated-tag', :on => true, :runner => 'bogusrunner'}) + }.to raise_error SystemExit + end + + it 'loads a custom runner when specified' do + $LOAD_PATH << 'spec/mocks' + require 'consolr/runners/testrunner' + expect_any_instance_of(Consolr::Runners::Testrunner).to receive(:initialize) + @console.start({:tag => 'safe-allocated-tag', :on => true, :runner => 'testrunner'}) + end + + it 'selects a runner that supports the node' do + $LOAD_PATH << 'spec/mocks' + require 'consolr/runners/testrunner' + require 'consolr/runners/failrunner' + old_config = ENV['CONSOLR_CONFIG'] + ENV['CONSOLR_CONFIG'] = '../../spec/configs/consolr_runners_rspec.yml' + + console = Consolr::Console.new + expect_any_instance_of(Consolr::Runners::Failrunner).to receive(:can_run?). + and_return(false) + expect_any_instance_of(Consolr::Runners::Testrunner).to receive(:on) + console.start({:tag => 'safe-allocated-tag', :on => true}) + + ENV['CONSOLR_CONFIG'] = old_config + end + safe_boolean_actions = {:console => "--> Opening SOL session (type ~~. to quit)\nsol activate", :kick => 'sol deactivate', :identify => 'chassis identify', :sdr => 'sdr elist all', :on => 'power on'} dangerous_boolean_actions = {:off => 'power off', :reboot => 'power cycle'} describe 'safe allocated asset' do safe_allocated_tag = 'safe-allocated-tag'