Sha256: 60b8b5acddc645201b8709cb0b612d89efac0ffd7f3eb2f1a9646d92e6eeb16c

Contents?: true

Size: 1.7 KB

Versions: 5

Compression:

Stored size: 1.7 KB

Contents

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

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

  subject { mid.call env }

  before do
    FileUtils.rm_rf path
    FileUtils.mkdir_p path

    Evrone::CI::Router.configure do |c|
      c.webdav_cache_url = 'http://localhost:8080'
    end
  end

  after { FileUtils.rm_rf path }

  it { should eq env }
  its(:init)             { should_not be_empty }
  its(:after_script)     { should_not be_empty }
  its(:webdav_cache_url) { should eq "http://localhost:8080/evrone-test-repo-rvm-2.0.0.tgz" }

  context "execute command" do
    include Evrone::Common::Spawn

    let(:init_script) { env.init.join("\n") }
    let(:after_script) { env.after_script.join("\n") }

    before do
      mid.call env
      init_script.gsub!("$HOME/cached", path)
      after_script.gsub!("$HOME/cached", path)
    end

    it "should be success" do
      out = ""

      code = spawn(init_script, chdir: path) do |o|
        out << o
        puts " ===> #{o}"
      end
      expect(code).to eq 0

      code = spawn(after_script, chdir: path) do |o|
        out << o
        puts " ===> #{o}"
      end
      expect(code).to eq 0

      #twice
      code = spawn(after_script, chdir: path) do |o|
        out << o
        puts " ===> #{o}"
      end
      expect(code).to eq 0

      expect(out).to match("adding /tmp/.test to cache")
      expect(out).to match("casher successfuly downloaded")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
evrone-ci-router-0.2.0.pre9 spec/lib/script_builder/webdav_cache_spec.rb
evrone-ci-router-0.2.0.pre8 spec/lib/script_builder/webdav_cache_spec.rb
evrone-ci-router-0.2.0.pre7 spec/lib/script_builder/webdav_cache_spec.rb
evrone-ci-router-0.2.0.pre6 spec/lib/script_builder/webdav_cache_spec.rb
evrone-ci-router-0.2.0.pre5 spec/lib/script_builder/webdav_cache_spec.rb