module Bacon_FS_Matchers::DSL

Public Instance Methods

directory() click to toggle source
# File lib/Bacon_FS_Matchers.rb, line 72
def directory
  lambda { |obj|
    File.directory?(obj)
    # should.flunk "#{obj.inspect} is not a directory."
  }
end
file() click to toggle source
# File lib/Bacon_FS_Matchers.rb, line 79
def file
  lambda { |obj|
    File.file?(obj)
    # should.flunk "#{obj.inspect} is not a file."
  }
end
file_containing(msg, show_contents = false) click to toggle source
# File lib/Bacon_FS_Matchers.rb, line 42
def file_containing msg, show_contents = false
  lambda { |obj|
    if not File.file?(obj)
      should.flunk "Not a file: #{obj}"
    end

    contents = File.read(obj)
    !!contents[msg]
  }
end
have_key(key) click to toggle source
# File lib/Bacon_FS_Matchers.rb, line 34
def have_key key

  matcher = lambda { |obj|
    obj.has_key?(key)
  }
  
end
have_permissions(str) click to toggle source
# File lib/Bacon_FS_Matchers.rb, line 62
def have_permissions str
  lambda { |obj|
    actual  = permissions(obj).first
    desired = str
    actual == desired
    # should.flunk "#{obj.inspect} permissions: #{actual} Should be: #{desired}"

  }
end
owned_and_in( user ) click to toggle source
# File lib/Bacon_FS_Matchers.rb, line 53
def owned_and_in( user )
  lambda { |obj|
    actual = permissions(obj)[1,2]
    desired = [ user, user ]
    actual == desired
    # should.flunk "#{obj.inspect} owner/group: #{actual} Should be: #{desired.inspect}"
  }
end