Based on your setup, that shouldn't really be an issue. The post you linked
to stated, that the root cause was that they had a module and a class with
the same name:

It was because I also had a class Admin, as well as a namespace Admin.
Since Admin was a class (a model) it inherited from Object which made the
top-level ApplicationController available inside the Admin namespace. The
reply by Andrew White on
http://groups.google.com/group/rubyonrails-core/browse_thread/thread/bab5e87ee10d2ecblead
me to find the right answer. In the end I renamed Admin to AdminUser
and everything fell into place.

I think this sort of base conflict is asking for heisenbugs, due to the
order that rails just happens to autoload first.

Are you sure that isn't what you have as well?

On Thu, Jul 4, 2013 at 11:21 AM, Gallagher Polyn <[email protected]>
wrote:

Hey,
>
> Using *spork*, *rspec-rails* and *rails 3*, I'm getting a 
> '*spec/models/price_request/integer_variable_spec.rb:4:
> warning: toplevel constant IntegerVariable referenced by
> PriceRequest::IntegerVariable*' warning and corresponding failures in the
> integer_variable_spec mentioned, due to a models namespace clash.
>
> Here's a simplified depiction of my rails app models directory (indicates
> basis for the clash):
>
> models/
>        integer_variable
>        price_request/
>                       integer_variable
>
> ... where the classes are named IntegerVariable and
> PriceRequest::IntegerVariable, respectively.
>
> As discussed at www.ruby-forum.com/topic/1506818, and with the chosen fix
> given specifically at
> code.dblock.org/warning-toplevel-constant-xyz-referenced-adminxyz, I
> added a line to spec_helper to modify the load order in hopes of resolving
> the problem:
>
> require 'rubygems'
> require 'spork'
>
> Spork.prefork do
>
>   ENV["RAILS_ENV"] ||= 'test'
>
>   require 'rails/application'
>   require 'rails/mongoid'
>
>   Spork.trap_class_method(Rails::Mongoid, :load_models)
>   Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
>
>   Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
>
>   require File.expand_path("../../config/environment", __FILE__)
>
>   # per
> http://code.dblock.org/warning-toplevel-constant-xyz-referenced-adminxyz
>   Dir[File.expand_path("app/models/price_request/*.rb")].each do |file|
>     require file
>   end
>   ...
>
> This resolves the problem, but spork no longer mirrors the code as it
> changes, rendering it useless.
>
> Anyone know where to insert the 'fix' line in the spec_helper, so that
> spork will work properly?
>
> Thanks,
>
> G
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/f5e90f8b-a63c-44cd-a78a-f0f22524ed6c%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CAKCESdhj%3D%3DF1TX-Y0rjgtG7TH58wCABCVgxyUf_1-nZuN55hVg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to