I'm running rspec with spork and I can't get a file in lib to reload on consecutive rspec runs. I've tried require'ing the file in 'Spork.each_run'
I'm not getting any responses, so I'll try to explain further. I have the following files in my Rails app:
To run tests, first I start spork then run 'rspec spec/lib/car_spec.rb'
RSpec is not seeing my changes to my Car class, unless I restart spork.
Any help?
I'm on:
Try to load
that file in Spork.each_run
instead of require
.
I hear you. Reloading of files in lib/ is very important.
When I do a require
directly (e.g. require "some_dir_under_lib/some_file"
), it doesn't get reloaded automatically. However, if I do
Dir["some_dir_under_lib/*.rb"].each { |file| require file }
then it DOES get reloaded automatically! I wish I could explain why!
Btw, I'm doing that in application.rb, not in spork/spec_helper stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With