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.19 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.18 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.17 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.16 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.15 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.14 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.13 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.12 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.11 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.10 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.9 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.8 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.7 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.6 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.5 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.4 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.3 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.2 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.1 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.0 spec/lib/builder/script_builder/prepare_spec.rb