BigW Consortium Gitlab

step_spec.rb 1.16 KB
Newer Older
1 2 3 4 5 6 7 8
require 'spec_helper'

describe Gitlab::Ci::Build::Step do
  let(:job) { create(:ci_build, :no_options, commands: "ls -la\ndate") }

  describe '#from_commands' do
    subject { described_class.from_commands(job) }

9 10 11 12 13 14 15
    it 'fabricates an object' do
      expect(subject.name).to eq(:script)
      expect(subject.script).to eq(['ls -la', 'date'])
      expect(subject.timeout).to eq(job.timeout)
      expect(subject.when).to eq('on_success')
      expect(subject.allow_failure).to be_falsey
    end
16 17 18 19 20 21
  end

  describe '#from_after_script' do
    subject { described_class.from_after_script(job) }

    context 'when after_script is empty' do
22 23 24
      it 'doesn not fabricate an object' do
        is_expected.to be_nil
      end
25 26 27
    end

    context 'when after_script is not empty' do
28
      let(:job) { create(:ci_build, options: { after_script: ['ls -la', 'date'] }) }
29

30 31 32 33 34 35 36
      it 'fabricates an object' do
        expect(subject.name).to eq(:after_script)
        expect(subject.script).to eq(['ls -la', 'date'])
        expect(subject.timeout).to eq(job.timeout)
        expect(subject.when).to eq('always')
        expect(subject.allow_failure).to be_truthy
      end
37 38
    end
  end
Tomasz Maczukin committed
39
end