Skip to content

Instantly share code, notes, and snippets.

@launchkit-codes
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save launchkit-codes/6b9488196e9db36f422f to your computer and use it in GitHub Desktop.

Select an option

Save launchkit-codes/6b9488196e9db36f422f to your computer and use it in GitHub Desktop.
Understand `require_relative`
# require_relative :
#
# Ruby tries to load the library named string relative to the requiring file’s path.
# If the file’s path cannot be determined a LoadError is raised.
# If a file is loaded true is returned and false otherwise.
#
# Tree directory:
#
# ./
# |- test
# |- test_helper.rb
# |- data
# |- clients.rb
#
# In ./test/test_helper.rb
require_relative 'data/clients' # ~= require "FILE_PATH/data/clients"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment