Sha256: 9d8765ea263505407f3b004b9ec63a15d8cb132c96d4768767eeb6f8830eecf9

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe Evrone::CI::ContainerConnector::Local do
  let(:conn) { described_class.new }
  subject { conn }

  it { should be }

  context "work_dir" do
    it "by default should be inside Dir.tmpdir" do
      expect(conn.work_dir).to eq("#{Dir.tmpdir}/.local_connector")
    end

    it "when passed via options, should be" do
      expect(described_class.new(work_dir: "/tmp").work_dir).to eq '/tmp'
    end
  end

  context "start container" do

    it "spawner id should eq local" do
      rs = nil
      conn.start do |spawner|
        rs = spawner.id
      end
      expect(rs).to eq 'local'
    end

    context "and spawn script" do
      it "successfuly" do
        rs   = ""
        code = nil

        conn.start do |spawner|
          code = spawner.spawn("echo $PWD") do |out|
            rs << out
          end
        end

        dir = "#{Dir.tmpdir}/.local_connector\n"
        if RUBY_PLATFORM =~ /darwin/
          dir.gsub!(/^\/var/, '/private/var')
        end

        expect(rs).to eq dir
        expect(code).to eq 0
      end

      it "failed" do
        code = nil
        rs   = ""
        conn.start do |spawner|
          code = spawner.spawn('ls /notexists') do |out|
            rs << out
          end
        end

        expect([1,2]).to be_include(code)
        expect(rs).to match(/No such file or directory/)
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evrone-ci-container_connector-0.2.0.pre28 spec/lib/local_spec.rb