Sha256: 2d1172a6c2f2dc7218f47281729a7b63736ee69dd2a437fd046b0ea1d5886e42
Contents?: true
Size: 1.86 KB
Versions: 6
Compression:
Stored size: 1.86 KB
Contents
# encoding: utf-8 require 'spec_helper' describe GitStorage do let(:git_repo) { File.join(working_directory, 'git_repo.git') } let(:compressor) do Class.new do def prepare(file) end end end let(:creator) do Class.new do attr_reader :content, :path, :name attr_accessor :compressed_content def initialize(path, content) @path = path @content = content @name = path.sub(/\..*$/, '').camelize.downcase.to_sym end def extension?(ext) ::File.extname(path) == ext end end end context '#files' do it 'returns a list of files matching pattern' do repo = GitRepository.create(git_repo) repo.add_content('file1.txt', 'asdf') repo.add_content('file2.pac', 'data file2.pac') storage = GitStorage.new(repo.storage_path, compressor, creator) expect(storage[:file2].content).to eq('data file2.pac') end it 'supports directories as well' do repo = GitRepository.create(git_repo) repo.add_content('file1.txt', 'asdf') repo.add_content('dir/file2.pac', 'data file2.pac') storage = GitStorage.new(repo.storage_path, compressor, creator) expect(storage['dir::file2'.to_sym].content).to eq('data file2.pac') end it 'supports deeply nested directories as well' do repo = GitRepository.create(git_repo) repo.add_content('file1.txt', 'asdf') repo.add_content('dir/dir1/file3.pac', 'data asdf.pac') storage = GitStorage.new(repo.storage_path, compressor, creator) expect(storage['dir::dir1::file3'.to_sym].content).to eq('data asdf.pac') end it 'handles a repo without a root commit' do repo = GitRepository.create(git_repo) storage = GitStorage.new(repo.storage_path, compressor, creator) expect(storage['dir::file2'.to_sym].content).to be_nil end end end
Version data entries
6 entries across 6 versions & 1 rubygems