Sha256: eb640cdd724af18f4caa61dd8c692ad28d2387ed8ae9f29b581fa5a98e1be045

Contents?: true

Size: 953 Bytes

Versions: 34

Compression:

Stored size: 953 Bytes

Contents

require 'helper'
require 'active_support/secure_random'

class TestDir < Test::Unit::TestCase
  
  include CSD
  
  context "When working with directories" do
  
    setup do
      @tmp     = Dir.mktmpdir
      @subdirs = []
      5.times { @subdirs << ActiveSupport::SecureRandom.hex(5) }
      @subdirs.each { |subdir| ensure_mkdir(File.join(@tmp, subdir)) }
    end

    teardown do
      assert FileUtils.rm_r(@tmp)
    end
    
    context "directories" do
  
      should "return all subdirectory names as an array" do
        result = Dir.directories(@tmp).map { |dirname| dirname }
        assert_equal @subdirs.sort, result.sort
      end
      
      should "yield all subdirectories in a block" do
        result = []
        Dir.directories(@tmp) { |dir| result << dir }
        assert_equal @subdirs.sort, Dir.directories(@tmp).sort
      end
      
    end # context "directories"
  
  end # context "When working with directories"
  
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
csd-0.4.3 test/unit/test_dir.rb
csd-0.4.2 test/unit/test_dir.rb
csd-0.4.1 test/unit/test_dir.rb
csd-0.4.0 test/unit/test_dir.rb
csd-0.3.7 test/unit/test_dir.rb
csd-0.3.6 test/unit/test_dir.rb
csd-0.3.5 test/unit/test_dir.rb
csd-0.3.4 test/unit/test_dir.rb
csd-0.3.3 test/unit/test_dir.rb
csd-0.3.2 test/unit/test_dir.rb
csd-0.3.1 test/unit/test_dir.rb
csd-0.3.0 test/unit/test_dir.rb
csd-0.2.2 test/unit/test_dir.rb
csd-0.2.1 test/unit/test_dir.rb
csd-0.2.0 test/unit/test_dir.rb
csd-0.1.18 test/unit/test_dir.rb
csd-0.1.17 test/unit/test_dir.rb
csd-0.1.16 test/unit/test_dir.rb
csd-0.1.15 test/unit/test_dir.rb
csd-0.1.14 test/unit/test_dir.rb