Sha256: 309ea10d5f5a453d196f283b8383ac50ee04d4412791f7ddbc8efb9fe256abb5

Contents?: true

Size: 1.58 KB

Versions: 10

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe "The Runner" do
  before(:all) do
    Net::SSH.stubs(:start).yields(SSHObject.new(:return_stream => :stdout, :return_data => "ok\n"))
    @server = Server.new :name => :server,  :address => "fake.com", :user => "fake"
    @task = Task.new :name => :test, :server => :server do
      run "one"
      run "two"
    end
  end

  it "should be able to execute commands on an address of a server" do
    Runner.stubs(:ssh_exec!).returns(["ok\n","",0,nil])

    commands = Runner.execute! :name => "test", 
      :server => @server, 
      :address => "fake.com", 
      :commands => @task.__build_commands, 
      :silent => true

    commands[0][:stderr].should == ""
    commands[0][:stdout].should == "ok\n"

    commands[1][:stderr].should == ""
    commands[1][:stdout].should == "ok\n"
  end

  it "should be able to handle error commands" do
    Runner.stubs(:ssh_exec!).returns(["ok\n","",0,nil]).then.returns(["","no\n",1,nil])
    commands = Runner.execute! :name => "test", 
      :server => @server, 
      :address => "fake.com", 
      :commands => @task.__build_commands, 
      :silent => true

    commands[0][:stderr].should == ""
    commands[0][:stdout].should == "ok\n"

    commands[1][:stderr].should == "no\n"
    commands[1][:stdout].should == ""
  end

  it "should be able to execute local commands" do
    task = Task.new :name => :localtest, :local => true do
      run "echo 'bongle'"
    end
    commands = Runner.execute_locally! :name => :localtest, :commands => task.__build_commands, :silent => true
    commands[0][:stdout].should == "bongle\n"
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
screwcap-0.6.2 spec/runner_spec.rb
screwcap-0.6.1 spec/runner_spec.rb
screwcap-0.6 spec/runner_spec.rb
screwcap-0.6.pre6 spec/runner_spec.rb
screwcap-0.6.pre5 spec/runner_spec.rb
screwcap-0.6.pre4 spec/runner_spec.rb
screwcap-0.6.pre3 spec/runner_spec.rb
screwcap-0.6.pre2 spec/runner_spec.rb
screwcap-0.6.pre spec/runner_spec.rb
screwcap-0.5 spec/runner_spec.rb