Sha256: 456b1d421631fe6e4faa865239b235e2e9ca32d54857b2592b72fa63b88f0ba6

Contents?: true

Size: 1006 Bytes

Versions: 11

Compression:

Stored size: 1006 Bytes

Contents

require 'spec/spec_helper'
require 'lib/stowaway/file'
require 'lib/stowaway/locator'

describe Stowaway::Locator do
  
  def locator
    @locator ||= Stowaway::Locator.new(%w{.txt})
  end
  
  it "should be initialized with an array of file extensions to locate" do
    locator.find_all('spec/data/').length.should == 2
  end
  
  it "should return an array of FileObj" do
    @f1 = Stowaway::FileObj.new('spec/data/testfile1.txt')
    locator.find_all('spec/data')[1].instance_of?(Stowaway::FileObj).should be_true
  end
  
  it "should return all matched files" do
    @f1 = Stowaway::FileObj.new('spec/data/testfile1.txt')
    @f2 = Stowaway::FileObj.new('spec/data/testfile2.txt')
    locator.find_all('spec/data/').should == [@f1, @f2]
  end
  
  it "should return true when file has the correct extension" do
    locator.type?('poop.txt').should be_true
  end
  
  it "should return false when file doesn't have the correct extension" do
    locator.type?('poop.stink').should be_false
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
stowaway-0.2.0 spec/lib/locator_spec.rb
stowaway-0.1.10 spec/lib/locator_spec.rb
stowaway-0.1.9 spec/lib/locator_spec.rb
stowaway-0.1.8 spec/lib/locator_spec.rb
stowaway-0.1.6 spec/lib/locator_spec.rb
stowaway-0.1.5 spec/lib/locator_spec.rb
stowaway-0.1.2 spec/lib/locator_spec.rb
stowaway-0.1.1 spec/lib/locator_spec.rb
stowaway-0.0.6 spec/lib/locator_spec.rb
stowaway-0.0.4 spec/lib/locator_spec.rb
stowaway-0.0.1 spec/lib/locator_spec.rb