Sha256: ac10ad106540edec56bdf653c54e70245281c1cfdf967fe67cd8e0a990728c34

Contents?: true

Size: 1.34 KB

Versions: 47

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'
require 'foreman/process'
require 'ostruct'
require 'timeout'
require 'tmpdir'

describe Foreman::Process do

  def run(process, options={})
    rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
    process.run(options.merge(:output => wr))
    rd.gets
  end

  describe "#run" do

    it "runs the process" do
      process = Foreman::Process.new(resource_path("bin/test"))
      run(process).should == "testing\n"
    end

    it "can set environment" do
      process = Foreman::Process.new(resource_path("bin/env FOO"), :env => { "FOO" => "bar" })
      run(process).should == "bar\n"
    end

    it "can set per-run environment" do
      process = Foreman::Process.new(resource_path("bin/env FOO"))
      run(process, :env => { "FOO" => "bar "}).should == "bar\n"
    end

    it "can handle env vars in the command" do
      process = Foreman::Process.new(resource_path("bin/echo $FOO"), :env => { "FOO" => "bar" })
      run(process).should == "bar\n"
    end

    it "can handle per-run env vars in the command" do
      process = Foreman::Process.new(resource_path("bin/echo $FOO"))
      run(process, :env => { "FOO" => "bar" }).should == "bar\n"
    end

    it "should output utf8 properly" do
      process = Foreman::Process.new(resource_path("bin/utf8"))
      run(process).should == "\xFF\x03\n"
    end
  end

end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
foreman-capistrano-0.53.4 spec/foreman/process_spec.rb
foreman-capistrano-0.53.3 spec/foreman/process_spec.rb
foreman-capistrano-0.53.2 spec/foreman/process_spec.rb
foreman-capistrano-0.53.1 spec/foreman/process_spec.rb
foreman-capistrano-0.53.0 spec/foreman/process_spec.rb
foreman-capistrano-0.52.6 spec/foreman/process_spec.rb
foreman-0.61.0-mingw32 spec/foreman/process_spec.rb
foreman-0.61.0-java spec/foreman/process_spec.rb
foreman-0.61.0 spec/foreman/process_spec.rb
foreman-capistrano-0.52.5 spec/foreman/process_spec.rb
foreman-capistrano-0.52.4 spec/foreman/process_spec.rb
foreman-capistrano-0.52.3 spec/foreman/process_spec.rb
foreman-capistrano-0.52.2 spec/foreman/process_spec.rb
foreman-capistrano-0.52.1 spec/foreman/process_spec.rb
foreman-capistrano-0.52.0 spec/foreman/process_spec.rb
foreman-capistrano-0.51.5 spec/foreman/process_spec.rb
foreman-0.60.2 spec/foreman/process_spec.rb
foreman-capistrano-0.51.4 spec/foreman/process_spec.rb
foreman-capistrano-0.51.3 spec/foreman/process_spec.rb
foreman-0.60.0 spec/foreman/process_spec.rb