Sha256: 70089d63f640b1e481b3c1ded7937aa5aa1afe6ded65aab54165a3f27d235d77

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe Vx::Builder::ScriptBuilderV2 do
  let(:task)   { create :task }
  let(:source) { create :source }
  let(:script) { described_class.new task, source }
  subject { script }

  context "just created" do
    its(:source) { should eq source }
    its(:task)   { should eq task  }
  end

  it "should avaialble timeout and read_timeout attributes" do
    expect(script.vexor.timeout).to eq 10
    expect(script.vexor.read_timeout).to eq 20

    simple_source = create :source, name: "simple.yml"
    simple_script = described_class.new task, simple_source
    expect(simple_script.vexor.timeout).to be_nil
    expect(simple_script.vexor.read_timeout).to be_nil
  end

  it "should create parallel jobs" do
    matrix = Vx::Builder::MatrixBuilder.new(source)
    configurations = matrix.build
    configuration = configurations[1]
    expect(configuration.parallel).to eq 3
    expect(configuration.parallel_job_number).to eq 1
    parallel_script = described_class.new task, configuration

    parallel_script.to_hash # call
    stage = parallel_script.stage("init")
    expect(stage.environment["CI_PARALLEL_JOBS"]).to eq 3
    expect(stage.environment["CI_PARALLEL_JOB_NUMBER"]).to eq 1
  end

  it "should able to convert to yaml" do
    yml = script.to_yaml
    fixture = "spec/fixtures/script_builder_v2/simple.yml"
    File.open(fixture, 'w') { |io| io.write yml }
    expect(script.to_yaml).to eq File.read(fixture)
  end

  it "should able to convert to script" do
    sh = script.to_script
    fixture = "spec/fixtures/script_builder_v2/simple.sh"
    File.open(fixture, 'w') { |io| io.write sh }
    expect(script.to_script).to be
  end

  it "adds user env variables" do
    hash  = script.to_hash
    stage = script.stage("init")
    expect(stage.environment["VX_USER_ENV"]).to eq '!test me'
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vx-builder-0.6.5 spec/lib/builder/script_builder_v2_spec.rb