diff options
author | bikebilly <fabio@gitlab.com> | 2017-08-03 10:05:56 +0200 |
---|---|---|
committer | bikebilly <fabio@gitlab.com> | 2017-08-03 10:05:56 +0200 |
commit | 40dfddd4077da4d594bd9e8956e1fcb1c99434e6 (patch) | |
tree | d0761ed84471c22b3b0949720e3e0734e8645aac /spec/lib/gitlab/ci/build/step_spec.rb | |
parent | ed5445388de13f1d126fec14cc0a9ea9ae03b397 (diff) | |
parent | dc412b48693668f7fba3adea57b8be76685afa76 (diff) | |
download | gitlab-ce-40dfddd4077da4d594bd9e8956e1fcb1c99434e6.tar.gz |
Merge branch 'master' into 33329-tech-article-deploying-maven-artifacts
Diffstat (limited to 'spec/lib/gitlab/ci/build/step_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/build/step_spec.rb | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/spec/lib/gitlab/ci/build/step_spec.rb b/spec/lib/gitlab/ci/build/step_spec.rb index 49457b129e3..5a21282712a 100644 --- a/spec/lib/gitlab/ci/build/step_spec.rb +++ b/spec/lib/gitlab/ci/build/step_spec.rb @@ -1,21 +1,50 @@ 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) } - - 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 + shared_examples 'has correct script' do + subject { described_class.from_commands(job) } + + it 'fabricates an object' do + expect(subject.name).to eq(:script) + expect(subject.script).to eq(script) + expect(subject.timeout).to eq(job.timeout) + expect(subject.when).to eq('on_success') + expect(subject.allow_failure).to be_falsey + end + end + + context 'when commands are specified' do + it_behaves_like 'has correct script' do + let(:job) { create(:ci_build, :no_options, commands: "ls -la\ndate") } + let(:script) { ['ls -la', 'date'] } + end + end + + context 'when script option is specified' do + it_behaves_like 'has correct script' do + let(:job) { create(:ci_build, :no_options, options: { script: ["ls -la\necho aaa", "date"] }) } + let(:script) { ["ls -la\necho aaa", 'date'] } + end + end + + context 'when before and script option is specified' do + it_behaves_like 'has correct script' do + let(:job) do + create(:ci_build, options: { + before_script: ["ls -la\necho aaa"], + script: ["date"] + }) + end + + let(:script) { ["ls -la\necho aaa", 'date'] } + end end end describe '#from_after_script' do + let(:job) { create(:ci_build) } + subject { described_class.from_after_script(job) } context 'when after_script is empty' do |