Nope, despite my efforts to repro this earlier, it's started
happening again.
Check out the output from autotest:
/usr/local/bin/ruby -S script/spec -O spec/spec.opts /Users/matt/
Documents/projects/songkick/skweb/app/controllers/admin/
cities_controller.rb spec/controllers/admin/cities_controller_spec.rb
/Users/matt/Documents/projects/songkick/skweb/app/controllers/admin/
cities_controller.rb:1: uninitialized constant Admin (NameError)
from /Users/matt/Documents/projects/songkick/skweb/vendor/
plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `load'
from /Users/matt/Documents/projects/songkick/skweb/vendor/
plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in `load_files'
from /Users/matt/Documents/projects/songkick/skweb/vendor/
plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in `each'
from /Users/matt/Documents/projects/songkick/skweb/vendor/
plugins/rspec/lib/spec/runner/example_group_runner.rb:13:in `load_files'
from /Users/matt/Documents/projects/songkick/skweb/vendor/
plugins/rspec/lib/spec/runner/options.rb:98:in `run_examples'
from /Users/matt/Documents/projects/songkick/skweb/vendor/
plugins/rspec/lib/spec/runner/command_line.rb:19:in `run'
from script/spec:4
/usr/local/bin/ruby -S script/spec -O spec/spec.opts /Users/matt/
Documents/projects/songkick/skweb/app/controllers/admin/
cities_controller.rb spec/controllers/admin/cities_controller_spec.rb
................
Finished in 0.183342 seconds
16 examples, 0 failures
The first time, I saved the controller, and it bombed. The second
time, I switched to the spec and saved that. Each time it looks as
though the same parameters are being passed to script/spec, but
something different is happening after that...
I've tried variously referring to the base class ::AdminController,
as Ben suggested but it doesn't seem to make any difference.
Right now, it looks like
class Admin::CitiesController < ::AdminController
Perhaps the reason the spec works is that it shares some behaviour
with the AdminController specs:
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/../
admin_controller_spec')
describe Admin::CitiesController do
it_should_behave_like "all admin controllers"
... etc
I'm using ZenTest 3.10.0 / Rails 2.1 / RSpec 1.1.4
cheers,
Matt
----
http://blog.mattwynne.net
http://songkick.com
In case you wondered: The opinions expressed in this email are my own
and do not necessarily reflect the views of any former, current or
future employers of mine.
On 18 Aug 2008, at 10:07, Matt Wynne wrote:
Thanks for the tips Ben.
We upgraded to Rails 2.1 (from 1.x) on Friday and this seems to
have gone away. I'll report back though if I learn anything else.
cheers,
Matt
----
http://blog.mattwynne.net
On 16 Aug 2008, at 20:32, Ben Mabey wrote:
Matt Wynne wrote:
I am writing a controller admin/cities_controller.rb
it inherits from AdminController, so it's defined like
class Admin::CitiesController > AdminController
Whenever I save the controller file, autotest freaks out:
uninitialized constant Admin::AdminController (NameError)
I'm pretty used to just hitting CTRL-C to get autotest to re-load
all
the files, or flicking to the spec file, and saving it to get a
similar effect.
But it is fairly irritating.
Any suggestions for how to hack autotest to get this to flow more
nicely?
Hmm... I am using namedspaced controllers on my current project
and I am
not running into those issues. I am using rspec edge, ZenTest 3.9.1,
and rails 2.1.0.
Have you copied your code exactly in your original email? If so, I
might see a difference in how we are doing things and that might
be your
problem.
My base controller is also namedspaced.. So in my app/controllers/
admin
dir I have the following:
base_contoller.rb:
module Admin
class BaseController < ::ApplicationController
....
end
end
Then:
other_controller.rb:
module Admin
class OtherController < BaseController
...
end
end
Note that I could also do:
base_contoller.rb:
class Admin::BaseController < ApplicationController
other_controller.rb:
class Admin::OtherController < Admin::BaseController
So.. If your AdminController is namespaced you should change your
other
controllers to:
class Admin::CitiesController < Admin::AdminController
If it is not namespaced (but, it really should be IMO) then you could
try this:
class Admin::CitiesController < ::AdminController
Hope that helps,
Ben
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users