Sha256: 8071daec77fd965821591d97ac1acc94264cbf812115ebbfe655d2c077c2f393

Contents?: true

Size: 1.35 KB

Versions: 22

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe Evrone::CI::Worker::DockerScript, run_docker: true do
  let(:exit_code)     { 0 }
  let(:app)           { ->(_) { exit_code } }
  let(:script)        { "echo script" }
  let(:before_script) { "echo before_script" }
  let(:after_script)  { "echo after_script" }
  let(:job)           { create :job,
                          script: script,
                          before_script: before_script,
                          after_script: after_script }
  let(:env)           { OpenStruct.new job: job }
  let(:mid)           { described_class.new app }
  let(:docker_mid)    { Evrone::CI::Worker::DockerStartContainer.new(mid) }

  subject { docker_mid.call env }

  before do
    stub(env).docker_repo_dir { Pathname.new '/tmp' }
  end

  it "should be" do
    expect(subject).to eq 0
    job.release
    expect(all_job_log_output).to match("script")
    expect(all_job_log_output).to match("after_script")
  end

  context "when script failed" do
    let(:script) { "false" }
    it "should be" do
      expect(subject).to eq(1)
      job.release
      expect(all_job_log_output).to match("after_script")
    end
  end

  context "when  before_script failed" do
    let(:before_script) { "false" }
    it "should be" do
      expect(subject).to eq(-1)
      job.release
      expect(all_job_log_output).to match("after_script")
    end
  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/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre26 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre25 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre24 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre23 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre22 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre21 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre20 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre19 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre18 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre17 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre15 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre14 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre13 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre12 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre11 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre10 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre9 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre8 spec/lib/worker/middlewares/docker_script_spec.rb
evrone-ci-worker-0.2.0.pre7 spec/lib/worker/middlewares/docker_script_spec.rb