require 'spec_helper' describe Evrone::CI::Worker::DockerWebdavCache, run_docker: true, webdav: true do let(:exit_code) { 0 } let(:app) { ->(env) { file = "$HOME/cached/foo.txt" cmd = %{ if [ -f #{file} ] ; then echo "!exists" ; cat #{file} ; else echo "!touch" ; echo 1 > #{file} ; fi }.compact env.ssh.spawn cmd, &job.method(:add_to_output) } } let(:job) { create :job } let(:env) { OpenStruct.new job: job } let(:mid) { described_class.new app } let(:docker_mid) { Evrone::CI::Worker::DockerStartContainer.new(mid) } subject { docker_mid.call env } before do Evrone::CI::Worker.config.webdav_cache_url = 'http://192.168.44.1:8080/' end context "first run" do it "should be" do expect(subject).to eq 0 end end context "next run" do before do expect(docker_mid.call env).to eq 0 job.output.clear end it "should be" do expect(subject).to eq 0 expect(job.output).to match(/\!exists/) end end end