require 'spec_helper' require 'pathname' require 'fileutils' describe Evrone::CI::Router::Middleware::FetchSource do let(:path_prefix) { '/tmp/.test' } let(:build) { create :build, options } let(:options) { {} } let(:repo_dir) { Pathname.new '/tmp/.test' } let(:app) { ->(_) { 0 } } let(:env) { OpenStruct.new build: build, repo_dir: repo_dir } subject { described_class.new(app).call env } before { FileUtils.rm_rf(repo_dir) } after { FileUtils.rm_rf(repo_dir) } it "should checkout repo" do expect(subject).to eq 0 expect(File.directory? "/tmp/.test/.git").to be end context "when failed" do let(:options) { { src: "/not-exists.git" } } it { should eq(-1) } end end