spec/beaker/dsl/helpers/host_helpers_spec.rb in beaker-3.37.0 vs spec/beaker/dsl/helpers/host_helpers_spec.rb in beaker-4.0.0

- old
+ new

@@ -350,61 +350,10 @@ subject.create_remote_file( hosts, '/remote/path', 'blah', my_opts ) end end - describe '#create_tmpdir_on' do - let(:host) { {'user' => 'puppet'} } - let(:result) { double.as_null_object } - - before :each do - allow(host).to receive(:result).and_return(result) - allow(result).to receive(:exit_code).and_return(0) - allow(result).to receive(:stdout).and_return('puppet') - end - - context 'with no user argument' do - - context 'with no path name argument' do - it 'executes chown once' do - expect(subject).to receive(:on).with(host, /^getent passwd puppet/).and_return(result) - expect(host).to receive(:tmpdir).with(/\/tmp\/beaker.*/) - expect(subject).to receive(:on).with(host, /chown puppet.puppet.*/) - subject.create_tmpdir_on(host, '/tmp/beaker') - end - end - - context 'with path name argument' do - it 'executes chown once' do - expect(subject).to receive(:on).with(host, /^getent passwd puppet/).and_return(result) - expect(host).to receive(:tmpdir).with(/\/tmp\/bogus.*/).and_return("/tmp/bogus") - expect(subject).to receive(:on).with(host, /chown puppet.puppet \/tmp\/bogus.*/) - subject.create_tmpdir_on(host, "/tmp/bogus") - end - end - end - - context 'with an valid user argument' do - it 'executes chown once' do - expect(subject).to receive(:on).with(host, /^getent passwd curiousgeorge/).and_return(result) - expect(host).to receive(:tmpdir).with(/\/tmp\/bogus.*/).and_return("/tmp/bogus") - expect(subject).to receive(:on).with(host, /chown curiousgeorge.curiousgeorge \/tmp\/bogus.*/) - subject.create_tmpdir_on(host, "/tmp/bogus", "curiousgeorge") - end - end - - context 'with a invalid user argument' do - it 'executes chown once' do - allow(result).to receive(:exit_code).and_return(1) - expect(subject).to receive(:on).with(host, /^getent passwd curiousgeorge/).and_return(result) - expect{ - subject.create_tmpdir_on(host, "/tmp/bogus", "curiousgeorge") - }.to raise_error(RuntimeError, /User curiousgeorge does not exist on/) - end - end - end - describe '#run_script_on' do it 'scps the script to a tmpdir and executes it on host(s)' do expect( subject ).to receive( :scp_to ) expect( subject ).to receive( :on ) subject.run_script_on( 'host', '~/.bin/make-enterprisy' ) @@ -416,8 +365,22 @@ allow( subject ).to receive( :hosts ).and_return( hosts ) expect( subject ).to receive( :run_script_on ).with( master, "/tmp/test.sh", {}).once subject.run_script( '/tmp/test.sh' ) + end + end + + describe '#install_package' do + it 'delegates to Host#install_package with arguments on the passed Host' do + expect( host ).to receive( :install_package ).with( 'pkg_name', '', '1.2.3' ) + subject.install_package( host, 'pkg_name', '1.2.3' ) + end + end + + describe '#uninstall_package' do + it 'delegates to Host#uninstall_package on the passed Host' do + expect( host ).to receive( :uninstall_package ).with( 'pkg_name' ) + subject.uninstall_package( host, 'pkg_name' ) end end end