Sha256: 6fa18361d55ffcc0a344adcbb4ff1b8225c3538a1460068996f133180597695e

Contents?: true

Size: 1.13 KB

Versions: 60

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
require 'tmpdir'
require 'fileutils'

describe Vx::Builder::ScriptBuilder::Prepare do
  let(:path) { Dir.tmpdir }

  before { FileUtils.rm_rf(path) }
  after { FileUtils.rm_rf(path) }

  def new_command(options = {})
    options[:task]   ||= create(:task)
    options[:env]    ||= create(:env, task: options[:task])
    options[:app]    ||= ->(_) { 0 }
    options[:script] ||= described_class.new options[:app]
    options[:script].call(options[:env])

    options[:cmd]    ||= create(:command_from_env, env: options[:env])
    options[:cmd]
  end

  it "should successfuly run command" do
    cmd = new_command
    Dir.chdir(path) do
      system( cmd )
    end
    expect($?.to_i).to eq 0
  end

  it "should be fail if reference if not in tree" do
    cmd = new_command(task: create(:task, sha: '8f53c077072674972e21c82a286acc07fada0000'))
    Dir.chdir(path) do
      system( cmd )
    end
    expect($?.to_i).to_not eq 0
  end

  it "should successfuly run for pull request" do
    cmd = new_command task: create(:task, pull_request_id: 1)
    Dir.chdir(path) do
      system( cmd )
    end
    expect($?.to_i).to eq 0
  end

end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
vx-builder-0.5.41 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.38 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.37 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.36 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.35 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.34 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.33 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.32 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.31 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.30 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.29 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.28 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.27 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.26 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.25 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.24 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.23 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.22 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.21 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.20 spec/lib/builder/script_builder/prepare_spec.rb