Sha256: e908d1e7e0104f94bafc9f9a030099f81c4aeb2b1a9e924d98aca6d207751692

Contents?: true

Size: 843 Bytes

Versions: 7

Compression:

Stored size: 843 Bytes

Contents

require 'chake/node'
require 'chake/backend'


shared_examples "Chake::Backend" do |backend_class|

  let(:backend) { backend_class.new(node) }

  it('runs commands') do
    io = StringIO.new("line 1\nline 2\n")
    IO.should_receive(:popen).with(backend.command_runner + ['something']).and_return(io)
    backend.should_receive(:puts).with("myhost: $ something")
    backend.should_receive(:puts).with("myhost: line 1")
    backend.should_receive(:puts).with("myhost: line 2")
    backend.run('something')
  end

  it('runs as root') do
    backend.should_receive(:run).with('sudo sh -c "something"')
    backend.run_as_root('something')
  end

  it('does not use sudo if already root') do
    backend.node.stub(:username).and_return('root')
    backend.should_receive(:run).with('something')
    backend.run_as_root('something')
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chake-0.2.2 spec/spec_helper.rb
chake-0.2.1 spec/spec_helper.rb
chake-0.2 spec/spec_helper.rb
chake-0.1.7 spec/spec_helper.rb
chake-0.1.6 spec/spec_helper.rb
chake-0.1.5 spec/spec_helper.rb
chake-0.1.4 spec/spec_helper.rb