module Assertable

File

assertable.rb

Purpose

Useful assertions

Author

Jeff McAffee 03/28/2015

Public Instance Methods

assert_dir_exists(path) click to toggle source

File System Asserts

# File lib/portal_module/assertable.rb, line 27
def assert_dir_exists path
  path = Pathname(path)
  dir = path.dirname
  raise IOError, "No such directory - #{path}" unless dir.exist?
end
assert_dl_dir_is_configured() click to toggle source
# File lib/portal_module/assertable.rb, line 19
def assert_dl_dir_is_configured
  dd = PortalModule.configuration.download_dir
  if (dd.nil? || dd.to_s.empty?)
    raise ConfigurationError, "Download directory has not been configured"
  end
end
assert_file_exists(path) click to toggle source
# File lib/portal_module/assertable.rb, line 33
def assert_file_exists path
  path = Pathname(path)
  raise IOError, "File not found: #{path}" unless path.exist? && !path.directory?
end
assert_org_is_configured(org) click to toggle source

ConfigurationError Asserts

# File lib/portal_module/assertable.rb, line 13
def assert_org_is_configured org
  unless PortalModule.configuration.orgs.key?(org)
    raise ConfigurationError, "Org Unit has not been configured - #{org}"
  end
end