Sha256: e6805090fde2bd96b073fcb0b8c9c4edf4421182c3eb550d22214bc79b4bfe0c

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'
require 'smallcage'

describe SmallCage::Loader do

  before do
    @docroot = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
  end

  it "should load path value which returns Pathname object" do
    ldr = SmallCage::Loader.new(@docroot)
    obj = ldr.load(@docroot + "a/b/c/index.html.smc")

    obj["path"].should be_an_instance_of(Pathname)
    obj["path"].smc.should be_an_instance_of(Pathname)
    
    obj["path"].to_s.should =~ %r{^.+/a/b/c/index\.html$}
    obj["path"].smc.to_s.should =~ %r{^.+/a/b/c/index\.html\.smc$}
  end
  
  it "should be able to omit smc extention" do
    ldr = SmallCage::Loader.new(@docroot + "a/b/c/index.html")
    objects = []
    ldr.each_smc_obj do |o|
      objects << o
    end
    objects.size.should == 1
    obj = objects[0]
    obj["uri"].should == "/a/b/c/index.html"
    obj["uri"].smc.should == "/a/b/c/index.html.smc"
  end
  
  it "should find smc root dir" do
    path = @docroot + "a/b/c/index.html.smc"
    
    depth = 5
    root = SmallCage::Loader.find_root(path, depth)
    root.to_s.should =~ %r{^.+/data/htdocs1$}
    
    depth = 3
    lambda { SmallCage::Loader.find_root(path, depth) }.should raise_error
  end
  
  it "should load strings" do
    path = @docroot + "a/b/c/index.html.smc"
    ldr = SmallCage::Loader.new(path)

    root = SmallCage::Loader.find_root(path)
    objects = []
    ldr.each_smc_obj do |o|
      objects << o
    end
    objects[0]["strings"][0].should == "abc\ndef\n\nghi"
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
bluemark-smallcage-0.1.3 spec/loader_spec.rb
smallcage-0.1.1 spec/loader_spec.rb
smallcage-0.1.0 spec/loader_spec.rb
smallcage-0.1.3 spec/loader_spec.rb
smallcage-0.0.9 spec/loader_spec.rb
smallcage-0.1.2 spec/loader_spec.rb