Holden Glova <dsafari / paradise.net.nz> wrote:
>
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Hi everyone,
>
>This has confused me before and I don't know why this is
>happening. I have other code examples that show the exact
>same thing that I have done, and they seem to work without
>a hitch - I am clearly missing something so fundamentally
>stupid that I'm going to kick myself when I am corrected :)

I think we have all done that...

>This involves 3 files, they are structured as follows:
>
>code_dir
>      |
>      ----- testing_dir
>
>My testing_dir has one script (we'll call it "testScript")
>in it that will test code one level above it. I refer to
>that code with
>require "../file_i'm_testing"

Which loads that file but doesn't change your current working
directory.

>Now file_i'm_testing makes reference to it's superclass
>which is in another file so it requires that other file,
>correct?

Which won't be found because it is not in any directory listed
in $:.

>The first line of file_i'm_testing is a
>require 'my_superclass'.
>
>When i try and run this from my testing script which is in
>testing_dir i get the following error:
>
>../file_i'm_testing.rb:1: in `require': No such file to
>load -- my_superclass (LoadError)
>	from ../file_i'm_testing.rb:1
>	from testScript.rb:2: in `require'
>	from testScript.rb:2

Indicating that it isn't able to find the second library.

>What am I doing wrong here? To me it seems like a simple
>chain but obviously it isn't.

Try this:

  $:.push ".."
  require "file_i_am_testing"

Cheers,
Ben
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com