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(:job) { create :job, script: script, before_script: before_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 expect(job.output).to match("script") end context "when script failed" do let(:script) { "false" } it "should be" do expect(subject).to eq(1) end end context "when before_script failed" do let(:before_script) { "false" } it "should be" do expect(subject).to eq(-1) end end end