Sha256: c36712beeb7c790c29fcc3d018566138cfd16415a874d3e5b02017f562e7fd49

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

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

describe Stowaway::Sweeper do
  
  before(:each) do
    @f1 = Stowaway::FileObj.new('/fake/file1.jpg')
    @f2 = Stowaway::FileObj.new('/fake/file2.gif')
    @f3 = Stowaway::FileObj.new('/fake/file3.js')
    @f4 = Stowaway::FileObj.new('/fake/also/file3.js')
    @files = [@f1, @f2, @f3, @f4]
    @sweeper = Stowaway::Sweeper.new(@files)
  end
  
  it "should sweep through directory structure looking for matches" do
    @sweeper.sweep('.')
    @files.should be_empty
  end
  
  it "should not examine ignored file types" do
    @sweeper = Stowaway::Sweeper.new(@files, ["^\\.", ".rb", "testfile1"])
    @sweeper.sweep('.').length.should == 2
  end

  it "should read through the file looking for matches" do
    @sweeper.inspect_file('spec/data/testfile1.txt')
    @files.should == [@f3, @f4]
  end
  
  it "should remove matches from the list of files to find" do
    line = 'file2.gif, file3.js'
    @sweeper.remove_match line
    @files.should == [@f1]
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stowaway-0.0.4 spec/lib/sweeper_spec.rb