Adding a directory to $LOAD_PATH (Ruby)

前端 未结 7 1059
广开言路
广开言路 2020-11-28 01:48

I have seen two commonly used techniques for adding the directory of the file currently being executed to the $LOAD_PATH (or $:). I see the advantages of doing this in case

7条回答
  •  自闭症患者
    2020-11-28 02:13

    Best I have come across for adding a dir via relative path when using Rspec. I find it verbose enough but also still a nice one liner.

    $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
    

提交回复
热议问题