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.