-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incompatible with spring #309
Comments
You could do some fancyness around reloading the db yml and reconnecting the db, but I doubt this will be the only issue you run into, since every connection needs to be redone ... |
That will be awesome! |
maybe this could help: rails/spring#116 |
Spring doesn't completely reconfigure activerecord, which is required if you want to do the interpolation of TEST_ENV_NUMBER into your config. Putting into require "active_support/core_ext/module/aliasing"
require "spring/application"
class Spring::Application
def connect_database_with_reconfigure_database
disconnect_database
reconfigure_database
connect_database_without_reconfigure_database
end
alias_method_chain :connect_database, :reconfigure_database
def reconfigure_database
if active_record_configured?
ActiveRecord::Base.configurations =
Rails.application.config.database_configuration
end
end
end The problem is there's no nice place in the preload process to hook into, an after_fork isn't quite right because the database is already connected. Meh. |
@sj26 What about ActiveModel in MongoID ? |
@airtonsobral you'll probably need to customise your spring after_fork hook to do the same thing for mongo. |
@sj26 Tried you solution and it didn't work for me, unfortunately. :( I still have errors like this one:
That is sad. UPD: After |
there is now a $250 bounty for this issue https://www.bountysource.com/issues/1669551-incompatible-with-spring :) |
@sj26 your solution worked for me, after running |
make it pretty and go grab that money then :) |
@sj26 Do it, man. You should be rewarded according to your deserts! |
Is there a solution for mongoid? |
The solution of @sj26 did not work for me properly (also after In the end, we decided to simply disable Spring when running tests in parallel -- yes, it will be slightly slower as each worker has to boot; but that's not too important considering the test runtime on that project (a parallel run is still much faster). I just disabled Spring on the running_in_parallel = ENV.has_key?('TEST_ENV_NUMBER') || ARGV.any? { |arg| arg =~ /^parallel:/ }
begin
load File.expand_path("../spring", __FILE__) unless running_in_parallel
rescue LoadError
end |
@foobear Thank's, this is perfect for me :) |
@foobear worked swimmingly for me as well! thanks! |
does this look good ? |
@sj26 your solution worked smoothly for me, thanks! Note for guys who are using db-charmer, set DbCharmer.connections_should_exist to false for test env |
This worked for me: $ spring rake parallel:spec |
On top of @sj26 solution, I have to specify |
There is some info on this on the wiki https://github.com/grosser/parallel_tests/wiki |
hopefully fixed with 2.2.0 |
@sj26's monkey patch has made it to the wiki: https://github.com/grosser/parallel_tests/wiki/Spring Rferencing it here since that will most likely be the most up-to-date version going forward. |
This gem is incompatible with https://github.com/rails/spring . The problem seems to be that the <%= ENV['TEST_ENV_NUMBER'] %> in the database.yml is not reevaluated for each test that is spinned up.
I am using the follwing two gems:
gem "spring"
gem "spring-commands-rspec"
Is there a workaround i can use?
The text was updated successfully, but these errors were encountered: