[rspec-users] spec_server errors when reloading fixture replacement pl
Scott Taylor
scott at railsnewbie.com
Tue May 26 14:46:49 EDT 2009
On May 26, 2009, at 2:31 PM, Ben Mabey wrote:
> Scott Taylor wrote:
>>
>> On May 26, 2009, at 1:22 PM, Mark Wilden wrote:
>>
>>> On Sun, May 24, 2009 at 10:17 PM, Ben Mabey <ben at benmabey.com <mailto:ben at benmabey.com
>>> >> wrote:
>>>
>>>
>>> Well, so Spork was really created with testing in mind. It is
>>> more general purpose than spec_server though. You can use it
>>> with any Ruby project, not just Rails. You can also potentially
>>> use it with any other testing framework that adds support for it
>>> (I've been meaning to do this for Cucumber). I know that Tim's
>>> original work with Kernel.fork was actually dealing with Mongrel
>>> but I'm not sure what the exact details of it are. I'll try to
>>> find out for you though.
>>>
>>>
>>> Spork seems to have the same problem that I have with spec_server:
>>> it doesn't reload classes I change. So if I'm doing TDD between a
>>> model and its spec, it doesn't help.
>>
>> I noticed the same thing. It must be a bug in spork, correct?
>>
>> Scott
>
> What does your spec_helper look like?
>
> It should be something like:
>
> require 'rubygems'
> require 'spork'
>
> Spork.prefork do
> ENV["RAILS_ENV"] = "test"
> require File.expand_path(File.dirname(__FILE__) + "/../config/
> environment")
> # Load other stuff that only needs to be setup once and never
> reloaded (i.e. rspec and configuring it)
> end
>
> Spork.each_run do
> ActiveRecord::Base.establish_connection # make sure that the db
> connection is ready.
> require File.expand_path(RAILS_ROOT + "/spec/fixjour_builders.rb") #
> You could use FixtureReplacement, FactorGirl, etc...
> Spec::Runner.configure do |config|
> config.include Fixjour
> include SharedSpecHelpers
> include DatabaseHelpers
> include AuthenticatedTestHelper
> end
> end
>
>
>
> Keep in mind that the code in Spork.prefork must not require any of
> your models inadvertently. If your environment file does this or a
> plugin does then your models will not be reloaded. Look over your
> spec_helper file and try to see who is requiring your models
> initially. We have really only tested this on is our apps where Tim
> and I work... So, there could very well be bugs we need to iron out.
Sweet! Seems to be working great now.
Looks like the README has changed over the weekend - previously, I had
been starting the spec server with script/spec_server. Running spork
directly seems to work just fine.
Thanks a TON!
Scott
More information about the rspec-users
mailing list