# "rake test" broken after upgrade to 1.9.2 (NameError)

**URL:** <https://www.ruby-forum.com/t/rake-test-broken-after-upgrade-to-1-9-2-nameerror/193649>\
**Category:** Ruby\
**Created:** [August 21, 2010, 12:38am UTC](https://www.ruby-forum.com/t/rake-test-broken-after-upgrade-to-1-9-2-nameerror/193649 "2010-08-21T00:38:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_MSP\_Veith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecd19e/32.png) [@Eric\_MSP\_Veith](https://www.ruby-forum.com/u/Eric_MSP_Veith)\
**Post date:** [August 21, 2010, 12:38am UTC](https://www.ruby-forum.com/t/rake-test-broken-after-upgrade-to-1-9-2-nameerror/193649/1 "2010-08-21T00:38:42Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hello List,

I’ve got a quite deep class and directory hierarchy. It worked perfectly  
well with Ruby 1.9.1, but after the upgrade to 1.9.2 it ceased working.  
However, it is not the app itself that gets killed, but “rake test”.

This is my directory structure:

- —%\<—  
./Rakefile  
./src/gnyu  
./src/gnyu/gnyubuild.rb  
./src/gnyubuild\*  
./src/gnyu/gnyubuild  
./src/gnyu/gnyubuild/mode.rb  
./src/gnyu/gnyubuild/mode  
./src/gnyu/gnyubuild/mode/repository.rb  
./src/gnyu/config.rb
- —\>%—

Along with a mirrored structure under test/ instead of src, which  
contain  
the corresponding unit tests.

Now if I changed to src/ and run “ruby -I. ./gnyubuild”, it works out  
fine.  
However, running “rake test” fails:

- —%\<—  
/usr/bin/ruby -I"lib:src" “/usr/lib/ruby/1.9.1/rake/rake\_test\_loader.rb”  
“test/unit/gnyu/test\_config.rb” “test/unit/gnyu/gnyubuild/test\_mode.rb”  
/home/eveith/Development/GNyU/gnyubuild/src/gnyu/gnyubuild/mode/repository.rb:16:in  
`module:GNyU’: uninitialized constant GNyU::GNyUBuild::Mode  
(NameError)

# …

- —\>%—

The definitions of the constants are made in the corresponding files,  
all  
enclosed in a “module GNyU; … ; end” definition. So, e.g.,  
GNyU::Config  
has the following preamble:

- —%\<—  
module GNyU  
class GNyU::Config
# …
end  
end
- —\>%—

Plus, I use “require” to load the super-class, e.g.  
GNyU::GNyUBuild::Mode::Repository has a “require ‘gnyu/gnyubuild/mode’”  
in  
it.

The ./src/gnyu/gnyubuild.rb file does not only house the definition of  
the  
GNyU::GNyUBuild class, but also serves as a mediator. That is, it loads  
and  
initializes the different “mode classes”, and as such has statements  
along  
the lines of “require ‘gnyu/gnyubuild/mode/repository’” in it. Removing  
it  
immediately causes the tests to run smoothly again.

The question now is: Why are the tests failing, while a “normal” run of  
the  
software works? Is there some sort of “circular name resolution” thingy  
that  
kills me?

Thanks in advance for all answers. Let me know if you need some  
clarification.

```
  Eric

```

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkxvAIkACgkQhS0drJ3goJI29QCfUYUwRlUZnTxWahTNjYZWdMad  
TAsAn3wHrMrqElk/QuBdfZj1hFnSsjfv  
=gAhq  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Eric\_MSP\_Veith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecd19e/32.png) [@Eric\_MSP\_Veith](https://www.ruby-forum.com/u/Eric_MSP_Veith)\
**Post date:** [August 21, 2010, 12:55am UTC](https://www.ruby-forum.com/t/rake-test-broken-after-upgrade-to-1-9-2-nameerror/193649/2 "2010-08-21T00:55:41Z")

</div>

On Sat, Aug 21, 2010 at 3:54 AM, Eric MSP Veith  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> -----BEGIN PGP SIGNED MESSAGE-----  
> Hash: SHA1
> 
> Hello List,
> 
> I’ve got a quite deep class and directory hierarchy. It worked perfectly  
> well with Ruby 1.9.1, but after the upgrade to 1.9.2 it ceased working.

It’s probably the removal of “.” from the load path. Try adding

$: \<\< “.”

at the start of your rakefile and see if that helps matters.

martin

---

<div class="post-metadata">

**Author:** ![Eric\_MSP\_Veith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecd19e/32.png) [@Eric\_MSP\_Veith](https://www.ruby-forum.com/u/Eric_MSP_Veith)\
**Post date:** [August 21, 2010, 1:26am UTC](https://www.ruby-forum.com/t/rake-test-broken-after-upgrade-to-1-9-2-nameerror/193649/3 "2010-08-21T01:26:45Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Martin,

thanks for your answer!

On Friday 20 August 2010, Martin DeMello [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> It’s probably the removal of “.” from the load path. Try adding

Naw, it’s not. The rake TestTask already adds the “src” subdirectory to  
ruby’s include path, and adding “.” doesn’t bring any benefit. (Rakefile  
lies in the top project directory, tests are in the “test”  
sub-directory,  
and the actual sources reside in “src”).

I’m beginning to doubt that is has anything to do with $: at all (or the  
upgrade to 1.9.2 for this matter), but may be a sheer problem of my  
layout  
of the sources. Can anybody confirm this?

```
  Eric

```

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkxvDxUACgkQhS0drJ3goJIOugCfUvq5AtlKAVAgw1/jjO9WGqea  
jpYAn1rY9bIEFjpZlb+AIshWJqNowW7m  
=PX2d  
-----END PGP SIGNATURE-----
