Spork does not reload file in lib

I am running rspec with spork and I cannot get the file in lib to reboot on successive rspec starts. I tried to request a file in the "Spork.each_run" folder

I do not get any answers, so I will try to explain further. I have the following files in a Rails application:

  • Library /car.rb
  • Specifications / Library / car _spec.rb

To run the tests, first run spork, then run "rspec spec / lib / car_spec.rb"

RSpec does not see my changes in my Car class unless I restart spork.

Any help?

I am:

  • rails 3.1.0.rc6
  • rspec 2.6.0
  • spork 0.9.0.rc9
+8
ruby ruby-on-rails rspec spork
source share
3 answers

You should put car.rb in app/models .

-3
source share

Try load this file in Spork.each_run instead of require .

+4
source share

I hear you. Rebooting files in lib / is very important.

When I do require directly (for example, require "some_dir_under_lib/some_file" ), it does not restart automatically. However, if I do

Dir["some_dir_under_lib/*.rb"].each { |file| require file }

then it automatically reboots! I would like to explain why!

Btw, I do this in application.rb and not in spork / spec_helper.

+1
source share

All Articles