Sha256: 7cc64cfc833ccc05497e71975b19f526248904b3caa188165ab17defd30985fd
Contents?: true
Size: 1.65 KB
Versions: 19
Compression:
Stored size: 1.65 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require 'hx/backend/rawfiles' require 'enumerator' require 'set' require 'tmpdir' describe Hx::Backend::RawFiles do before :each do @dir = Dir.mktmpdir @input = Hx::Backend::RawFiles.new(Hx::NULL_INPUT, {:entry_dir => @dir}) end after :each do FileUtils.rm_rf @dir end it "should retrieve file content" do content = "foobar" File.open(File.join(@dir, 'test'), 'w') { |s| s.write(content) } @input.get_entry('test')['content'].to_s.should == content end it "should enumerate files" do entry_names = Set.new %q(foo bar baz) for name in entry_names File.open(File.join(@dir, name), 'w') {} end enum = Enumerable::Enumerator.new(@input, :each_entry_path, Hx::Path::ALL) Set.new(enum).should == entry_names end it "should retreive file content lazily" do real_content = "foobar" File.open(File.join(@dir, 'test'), 'w') { |s| s.write("blargh") } entry_content = @input.get_entry('test')['content'] File.open(File.join(@dir, 'test'), 'w') { |s| s.write(real_content) } entry_content.to_s.should == real_content end it "should retrieve file mtime" do File.open(File.join(@dir, 'test'), 'w') {} time = Time.at(0) File.utime(time, time, File.join(@dir, 'test')) @input.get_entry('test')['updated'].should == time end it "should return the executable bit" do File.open(File.join(@dir, 'regular'), 'w') {} File.open(File.join(@dir, 'executable'), 'w') { |s| s.chmod(0775) } @input.get_entry('regular')['executable'].should be_false @input.get_entry('executable')['executable'].should be_true end end
Version data entries
19 entries across 19 versions & 1 rubygems