require 'spec_helper' describe Evrone::CI::Worker::DockerBeforeScript, run_docker: true do let(:exit_code) { 0 } let(:app) { ->(_) { exit_code } } let(:script) { "echo before_script" } let(:job) { create :job, before_script: 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 { '/tmp' } end it "should be" do expect(subject).to eq 0 expect(job.output).to match("before_script") end context "when fail to execute" do let(:script) { "/bin/false" } it "should be" do expect(subject).to eq(-1) end end end