tags:

views:

151

answers:

1

I'm using a mocking framework add-on to RSpec called NotAMock (http://github.com/notahat/not%5Fa%5Fmock). I am modeling a business layer in Ruby, so my project consists of mostly plain-old Ruby objects (PORO's). I've put my specs in a 'specs' directory off of the project directory, and put NotAMock within the specs directory. When I run my specs, I do so out of the project root directory. However, NotAMock has its own directory, and includes files like 'require NotAMock/library' etc. Therefore, when I run the specs, I get an error saying a NotAMock file could not be found. Is there any way to add the NotAMock directory to RSpec's search path?

Here is an example of my project structure:

----- my_business_library1.rb

----- my_business_library2.rb

----| specs

  ----- spec1.rb
  ----- spec2.rb
  ----- not_a_mock.rb
  ----| NotAMock
        ----- not_a_mock_file1.rb
        ----- not_a_mock_file2.rb
+1  A: 

Maybe the "$LOAD_PATH" Variable can help you.
It stores the directories in which the require method searches for Ruby files

$LOAD_PATH << './NotAMock'
require 'NotAMock/library'
Marc Seeger
Thanks Marc. That would require adding that line to every spec file though right? Is there a way to avoid having to add it to every file?
Michael Brennan
I think you only have to modify the LOAD_PATH variable once since it's a global variable
Marc Seeger