Sha256: 5ce5c3dc1176f3e32e3f6f065bacc4bc16a1bf11a97627ef74c23d28cdaa83f5

Contents?: true

Size: 1.17 KB

Versions: 22

Compression:

Stored size: 1.17 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
    job.release
    expect(last_job_log_message.log).to be_include("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

22 entries across 22 versions & 1 rubygems

Version Path
evrone-ci-worker-0.2.0.pre27 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre26 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre25 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre24 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre23 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre22 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre21 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre20 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre19 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre18 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre17 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre15 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre14 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre13 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre12 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre11 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre10 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre9 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre8 spec/lib/worker/middlewares/local_script_spec.rb
evrone-ci-worker-0.2.0.pre7 spec/lib/worker/middlewares/local_script_spec.rb