Sha256: 12f6f67bd13a79adf4f46d12676a68872152fbe14571ac4a8f133fa05ba8fde1

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
require 'pathname'
require 'fileutils'

describe Evrone::CI::Worker::LocalScript do
  let(:before_script) { "echo before_script"  }
  let(:script)        { "echo script" }
  let(:app)           { ->(_) { 0 } }
  let(:job)           { create :job, script: script, before_script: before_script }
  let(:path_prefix)   { Pathname.new "/tmp/.ci" }
  let(:work_dir)      { path_prefix.join("work") }
  let(:tmp_dir)       { path_prefix.join("tmp") }
  let(:env)           { OpenStruct.new job: job, work_dir: work_dir, tmp_dir: tmp_dir }
  let(:mid)           { described_class.new app }

  subject { mid.call env }

  after do
    FileUtils.rm_rf path_prefix
  end

  before do
    FileUtils.mkdir_p work_dir
    FileUtils.mkdir_p tmp_dir
  end

  it { should eq 0 }

  it "should capture output" do
    subject
    expect(job.output).to eq "before_script\nscript\n"
  end

  context "when script failed" do
    let(:script) { 'false' }
    it { should satisfy { |n| [1,127].include?(n) } }
  end

  context "when before_script failed" do
    let(:before_script) { 'false' }
    it { should satisfy { |n| [-1,-127].include?(n) } }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evrone-ci-worker-0.2.0.pre4 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre3 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre1 spec/lib/worker/middlewares/local_script_spec.rb