Sha256: ca7123c8fd2e42a8c9ce3f3d95d102012ab6a28f46d64d24b4095453e2f2aae4

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'
require 'deployml/remote_shell'

describe RemoteShell do
  let(:uri) { 'ssh://deploy@www.example.com/path' }

  subject { RemoteShell.new(uri) }

  it "should parse the given URI" do
    subject.uri.should be_kind_of(Addressable::URI)

    subject.uri.user.should == 'deploy'
    subject.uri.host.should == 'www.example.com'
    subject.uri.path.should == '/path'
  end

  it "should convert normal URIs to SSH URIs" do
    subject.ssh_uri.should == 'deploy@www.example.com'
  end

  it "should enqueue programs to run" do
    subject.run 'echo', 'one'
    subject.run 'echo', 'two'

    subject.history[0].should == ['echo', 'one']
    subject.history[1].should == ['echo', 'two']
  end

  it "should enqueue echo commands" do
    subject.echo 'one'
    subject.echo 'two'

    subject.history[0].should == ['echo', 'one']
    subject.history[1].should == ['echo', 'two']
  end

  it "should enqueue directory changes" do
    subject.cd '/other'

    subject.history[0].should == ['cd', '/other']
  end

  it "should enqueue temporary directory changes" do
    subject.cd '/other' do
      subject.run 'pwd'
    end

    subject.history[0].should == ['cd', '/other']
    subject.history[1].should == ['pwd']
    subject.history[2].should == ['cd', '-']
  end

  it "should join all commands together into one command" do
    subject.run 'echo', 'one'
    subject.run 'echo', 'two'

    subject.join.should == 'echo one && echo two'
  end

  it "should escape all command arguments" do
    subject.run 'the program'
    subject.run 'echo', '>>> status'

    subject.join.should == "the\\ program && echo \\>\\>\\>\\ status"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deployml-0.4.2 spec/remote_shell_spec.rb
deployml-0.4.1 spec/remote_shell_spec.rb
deployml-0.4.0 spec/remote_shell_spec.rb