Sha256: 67b9fb9c35c8207cb55c151fb728ef1af6c814e528d8088e1fc861bd89b0fe09

Contents?: true

Size: 1.93 KB

Versions: 5

Compression:

Stored size: 1.93 KB

Contents

require 'helper'

class TestGlobbing < FunWith::Files::TestCase
  context "testing globbing" do
    setup do
      @loadable_dir = FunWith::Files.root "test", "loadable_dir"
      @glob_dir     = FunWith::Files.root "test", "glob_dir" 
      assert @loadable_dir.directory?
      assert @glob_dir.directory?
    end
  
    should "glob some ruby files from the test/loadable_dir directory" do
      globs = @loadable_dir.glob( :recursive => true, :ext => "rb" )
      assert_equal 8, globs.length
    end
  
    should "only glob the top-level when recurse is false" do
      globs = @loadable_dir.glob( :recurse => false )
      assert_equal( 5, globs.length )

      globs = @loadable_dir.glob( :all, :recurse => false )
      assert_equal( 5, globs.length )
    end
    
    should "glob everything in the tree by default" do
      globs = @loadable_dir.glob
      assert_equal( 13, globs.length )

      globs = @loadable_dir.glob(:all)
      assert_equal( 13, globs.length )
    end
    
    should "glob only files when an extension is given" do
      globs = @loadable_dir.glob( :recurse => true, :ext => :rb )
      assert_equal( 8, globs.length )
    end
    
    should "not search subdirectories when :recurse => false" do
      globs = @loadable_dir.glob( :recurse => false, :ext => :rb )
      assert_length 0, globs
    end
    
    should "NOT search subdirectories when :recurse is unspecified" do
      globs = @loadable_dir.glob :ext => :rb
      assert_length 0, globs
    end
    
    should "glob a dot file" do
      globs = @glob_dir.glob( :recurse => false, :dots => true )
      assert_length 1, globs
    end
    
    should "not glob a dot file when :dots => false" do
      globs = @glob_dir.glob( :recurse => false, :dots => false )
      assert_length( 0, globs )
    end
    
    should "ignore a dot file by default" do
      globs = @glob_dir.glob( :recurse => false )  # no dots by default
      assert_length( 0, globs )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fun_with_files-0.0.18 ./test/test_globbing.rb
fun_with_files-0.0.15 ./test/test_globbing.rb
fun_with_files-0.0.14 ./test/test_globbing.rb
fun_with_files-0.0.13 ./test/test_globbing.rb
fun_with_files-0.0.12 ./test/test_globbing.rb