require 'spec_helper' require 'pathname' require 'fileutils' describe Evrone::CI::Router::Middleware::CreateDirs do let(:build) { create :build } let(:path_prefix) { Pathname.new '/tmp/.test' } let(:app) { ->(_) { 0 } } let(:env) { OpenStruct.new build: build, path_prefix: path_prefix } subject { described_class.new app } before { FileUtils.rm_rf path_prefix } after { FileUtils.rm_rf path_prefix } context "call" do subject{ described_class.new(app).call env } it { should eq 0 } it "should create and assign to env repo_dir" do subject expect(env.repo_dir.to_s).to eq '/tmp/.test/repo' expect(File.directory? env.repo_dir).to be end end end