Sha256: 7aff7828b302dff691c8e624063e5db6b28092d4cb776aeaff484026b88459af

Contents?: true

Size: 1.11 KB

Versions: 23

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'evrone/common/spawn'
require 'fileutils'

describe Evrone::CI::Router::ScriptBuilder::Prepare do
  let(:path)  { '/tmp/.test' }
  let(:app)   { ->(_) { _ } }
  let(:build) { create :build }
  let(:env)   { OpenStruct.new build: build, init: [] }
  let(:mid)   { described_class.new app }

  subject { mid.call env }

  before do
    FileUtils.rm_rf path
    FileUtils.mkdir_p path
  end

  after { FileUtils.rm_rf path }

  it { should eq env }
  its(:init) { should_not be_empty }

  context "run compiled script" do
    include Evrone::Common::Spawn

    let(:script) { "set -e\nset -x\n" + env.init.join("\n") }
    before { mid.call env }

    it "should be success" do

      code = spawn script, chdir: path do |out|
        puts " ===> #{out}"
      end

      expect(code).to eq 0
      expect(File).to be_readable("#{path}/data/evrone/test-repo/git_ssh")
      expect(File).to be_readable("#{path}/data/evrone/test-repo/key")
      expect(File).to be_directory("#{path}/code/evrone/test-repo/.git")
      expect(File).to be_readable("#{path}/code/evrone/test-repo/Rakefile")
    end

  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
evrone-ci-router-0.2.0.pre28 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre27 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre26 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre25 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre24 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre23 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre22 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre21 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre20 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre19 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre18 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre17 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre15 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre14 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre13 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre12 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre11 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre10 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre9 spec/lib/script_builder/prepare_spec.rb
evrone-ci-router-0.2.0.pre8 spec/lib/script_builder/prepare_spec.rb