Sha256: a5e635b8632636870122be63f8a31f5080583c7893ab1dc22b80216b6dd41112

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

# encoding: utf-8
require 'jldrill/model/LoadPath'
require 'jldrill/model/Config'

module JLDrill

	describe LoadPath do
        it "should not find files if empty" do
            lp = LoadPath.new
            lp.empty?().should eql(true)
            lp.find("file").should eql(nil)
        end

        it "should be able to add a directory to the load path" do
            lp = LoadPath.new
            firstDir = File.join(Config::DATA_DIR, "tests/first")
            lp.add(firstDir)
            lp.empty?().should eql(false)
            lp.to_s.should eql(firstDir)
            lp.find("file").should eql(File.join(firstDir, "file"))
        end

        it "should not find files that don't exist" do
            lp = LoadPath.new
            firstDir = File.join(Config::DATA_DIR, "tests/first")
            lp.add(firstDir)
            lp.find("bogus").should eql(nil)
        end

        it "should prioritize directories added first" do
            lp = LoadPath.new
            firstDir = File.join(Config::DATA_DIR, "tests/first")
            secondDir = File.join(Config::DATA_DIR, "tests/second")
            neverDir = File.join(Config::DATA_DIR, "tests/Never")
            lp.add(firstDir)
            lp.add(secondDir)
            lp.add(neverDir)
            lp.to_s.should eql("#{firstDir}:#{secondDir}:#{neverDir}")
            lp.find("bogus").should eql(nil)
            lp.find("file").should eql(File.join(firstDir, "file"))
            lp.find("file2").should eql(File.join(secondDir, "file2"))
        end

        it "should not add a nil path" do
            lp = LoadPath.new
            lp.add(nil)
            lp.empty?.should eql(true)
            lp.find("bogus").should eql(nil)
        end
    end
end
	

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.6.0.1 spec/jldrill/model/LoadPath_spec.rb