Sha256: 72a6f33d9ab7d05cacefcbf4d35ec898645b97377729d0fe4bc9071d9e417e8b

Contents?: true

Size: 835 Bytes

Versions: 3

Compression:

Stored size: 835 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 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

3 entries across 3 versions & 1 rubygems

Version Path
chake-0.1.3 spec/spec_helper.rb
chake-0.1.2 spec/spec_helper.rb
chake-0.1.1 spec/spec_helper.rb