Sha256: 3dec9ec99cf38a5ab031039082e9e9956138cbf47cf797b8a257e8b7302e555b
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
require 'fileutils' require 'hashery' require 'awestruct/handlers/file_handler' describe Awestruct::Handlers::FileHandler do before :all do @site = Hashery::OpenCascade[ { :encoding=>false, :dir=>Pathname.new( test_data_dir '' )}] end it "should be able to read a valid absolute file handler" do filename = Pathname.new( test_data_dir 'simple-file.txt' ) handler = Awestruct::Handlers::FileHandler.new( @site, filename ) handler.raw_content.strip.should == 'howdy' end it "should be able to read a valid relative file handler" do filename = Pathname.new( test_data_dir 'simple-file.txt' ) pwd = Pathname.new( Dir.pwd ) handler = Awestruct::Handlers::FileHandler.new( @site, filename.relative_path_from( pwd ) ) handler.raw_content.strip.should == 'howdy' end it "should be stale before being read" do filename = Pathname.new( test_data_dir 'simple-file.txt' ) handler = Awestruct::Handlers::FileHandler.new( @site, filename ) handler.should be_stale end it "should not be stale after being read" do filename = Pathname.new( test_data_dir 'simple-file.txt' ) handler = Awestruct::Handlers::FileHandler.new( @site, filename ) handler.raw_content.strip.should == 'howdy' handler.should_not be_stale end it "should be stale if touched after being read" do filename = Pathname.new( test_data_dir 'simple-file.txt' ) handler = Awestruct::Handlers::FileHandler.new( @site, filename ) handler.raw_content.strip.should == 'howdy' handler.should_not be_stale sleep(1) FileUtils.touch( filename ) handler.should be_stale end it "should provide reasonable paths" do filename = Pathname.new( test_data_dir 'simple-file.txt' ) handler = Awestruct::Handlers::FileHandler.new( @site, filename ) handler.relative_source_path.should == '/simple-file.txt' handler.output_filename.should == 'simple-file.txt' handler.output_extension.should == '.txt' handler.output_path.should == '/simple-file.txt' end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
awestruct-0.5.4.2 | spec/awestruct/handlers/file_handler_spec.rb |
awestruct-0.5.4.1 | spec/awestruct/handlers/file_handler_spec.rb |
awestruct-0.5.4 | spec/awestruct/handlers/file_handler_spec.rb |