Sha256: bcc6ff67d2a4ff572fad07dfba207ddb474f5b4027c7b79bf48c9ef728ac8ebb

Contents?: true

Size: 900 Bytes

Versions: 7

Compression:

Stored size: 900 Bytes

Contents

require 'minitest_helper'

describe Datacenter::Shell do
  
  module SharedExpamples
    it 'Success' do
      filename = File.join '/tmp', Time.now.to_i.to_s
      shell.run "echo \"test file\" > #{filename}"
      shell.run("cat #{filename}").must_equal 'test file'
    end

    it 'Error' do
      filename = '/invalid_dir/invalid_file'
      shell.run("cat #{filename}").must_equal "cat: #{filename}: No such file or directory"
    end
  end

  describe 'Local' do

    let(:shell) { Datacenter::Shell::Local.new }

    include SharedExpamples

  end

  describe 'Remote' do

    let(:connection_args) { ['localhost', `whoami`.strip] }
    let(:shell) { Datacenter::Shell::Remote.new *connection_args }

    include SharedExpamples

    it 'Block' do
      Datacenter::Shell::Remote.open(*connection_args) do |shell|
        shell.run('ls /').must_equal `ls /`.strip
      end
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
datacenter-0.3.1 spec/shell_spec.rb
datacenter-0.2.2 spec/shell_spec.rb
datacenter-0.2.1 spec/shell_spec.rb
datacenter-0.2.0 spec/shell_spec.rb
datacenter-0.1.2 spec/shell_spec.rb
datacenter-0.1.1 spec/shell_spec.rb
datacenter-0.1.0 spec/shell_spec.rb