MySQL server has gone away with Rails, Sunspot and Cucumber

When using Rails, sunspot and cucumber with a mysql test database, I received the following the MySQL server has gone away error.
After some googling a came across the `reconnect` option for database config

1
2
3
4
Using the default profile...
Sunspot server is starting...
Sunspot server took 2.72 sec. to get up and running. Let's cuke!
Mysql::Error: MySQL server has gone away: SHOW TABLES (ActiveRecord::StatementInvalid)

Solution is to add

1
reconnect: true

to cucumber section of your database.yml

Thanks to: http://rywalker.com/

One thought on “MySQL server has gone away with Rails, Sunspot and Cucumber

  1. For what it’s worth, only the MySQL driver implements `reconnect`, at least the PostgreSQL driver doesn’t. I can’t speak for SQLite, or any of the other adapters.

Leave a Comment