require 'spec_helper' require 'pathname' require 'fileutils' describe Evrone::CI::Worker::LocalBeforeScript do let(:command) { "echo before_script" } let(:app) { ->(_) { 0 } } let(:job) { create :job, before_script: command } let(:work_dir) { Pathname.new '/tmp/.ci' } let(:env) { OpenStruct.new job: job, work_dir: work_dir } let(:mid) { described_class.new app } subject { mid.call env } after do FileUtils.rm_rf work_dir end before do FileUtils.mkdir_p work_dir end it { should eq 0 } it "should capture output" do subject expect(job.output).to eq "before_script\n" end context "when script failed" do let(:command) { '/bin/false' } it { should eq(-1) } end end