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.61 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.60 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.59 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.58 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.57 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.56 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.55 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.54 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.53 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.52 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.51 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.50 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.49 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.48 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.47 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.46 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.45 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.44 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.43 spec/lib/builder/script_builder/prepare_spec.rb
vx-builder-0.5.42 spec/lib/builder/script_builder/prepare_spec.rb