David - Musings of an SRE

Redis::InheritedError during RSpec/Spork Testing

When testing an action that performs a redis-rb command on RSpec, you may run into an error:

Redis::InheritedError (Tried to use a connection from a child process without reconnecting ...

Solve it by adding the following into your spec_helper.

# spec/spec_helper.rb
RSpec.configure do |config| 
  # ... 
  config.before :all do
    $redis.client.reconnect 
  end 
  # ... 
end

Saves me ton of time.

Reference: Stackoverflow