On Mar 29, 2008, at 11:11 PM, David Beckwith wrote:

> Just to help clarify for the newbies like me.  script/spec_server runs
> in conjunction with script/spec but not ruby your_spec.rb.  It seems
> like the way to use script/spec_server is to have 2 console programs
> open:
>
>  ruby script/spec_server
>
> That will have the spec_server running in the background and your
> entire application loaded into memory at the time of execution, and
> since it's on top of once console it will be easy to kill and restart
> when you need to.  If you make changes to your application that are
> loaded up only in the beginning (like installing a new plugin), then
> you'll have to restart spec_server.  (Q: What about the following
> cases:
> make a database schema change,
> add another user-defined model,
> add another controller,
> edit an existing controller,
> edit an existing model
> make changes to your routes.rb file,
> edit a plugin.
> For which of those cases do you have to restart spec_server and which
> cases don't you? )

I'm replying in chunks here, but:

AFAIK, anything which is required will need to be reloaded (if it  
changes).  Also - any change to rails itself.

Schema changes will require you to reload the server.  Not sure about  
a new model, but, if you say, added a new column to a table, you would  
most certainly need to reload the spec_server (as rails actually  
caches ActiveRecord::Base.columns, much to my chagrin the other day in  
a migration).

Anything which is loaded with Kernel#load (or load_once, or whatever  
rails does) shouldn't cause you to reload the spec server. So - this  
means changes to the code of a model or a controller should be safe,  
since they are load'ed, not required (as require does nothing but  
return false the second time it is called).

I'm not sure about the routes or the plugin scenario.  I would assume  
for the plugin that it depends on how the code is internally loaded  
up.  If it is require'd instead of load'ed, I'd bet that you need to  
change the spec_server.

Also - just a tip for those who might be using (or thinking of using)  
the spec_server: I've noticed that shared example groups aren't being  
reloaded properly.  This is a bug in rspec which I've yet to file a  
ticket for, mainly out of lack of time.  Next time I run across it,  
I'll report it.

Scott


_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to