Everyday Rails

Working around the mimemagic issue in my RSpec testing book

By Aaron Sumner, April 05, 2021. File under: .

As you may have heard, the Rails community has a brief moment of panic and drama a few weeks ago, when the mimemagic gem’s version number was bumped while addressing a licensing concern. Previous versions of the gem with an incorrect license were yanked and no longer downloadable.

This change affected thousands of Rails applications—even tiny ones like the sample source for my introductory book about Rails testing, Everyday Rails Testing with RSpec. The subject matter of the book itself doesn’t depend on mimemagic, but I used the Paperclip gem to add file upload support in order to demonstrate how to test such functionality–and Paperclip (at least the version I used) depends on mimemagic.

Due to the structure of the book’s sample code, I do not plan on updating it at this time to address the version change. Each chapter builds upon the previous one. In the sample code, this is handled by a long-running git branch for each chapter. Making a change to the core application requires a change to the first chapter’s branch; then, I merge the changes on up through each subsequent branch. Since many chapters’ branches make changes to the project’s Gemfile and Gemfile.lock, this approach is prone to error. And I would rather spend my time thinking about what a version of the tutorial might look like for a more modern version of Rails.

Working around the problem

Junichi Ito, who leads the team responsible for the Japanese translation of the book, has reported a workaround: Instead of running bundle install to set up the initial application, run bundle update mimemagic instead. This will pull down a version of mimemagic with its updated license, so you can complete the exercises in the book.

Thank you very much to Junichi for his diligence on this matter, and sharing the solution. I apologize for the confusion and frustration this no doubt caused many of you, and appreciate your support.

What do you think? Follow along on on Twitter or Facebook to let me know what you think and catch my latest posts. Better yet, subscribe to my newsletter for updates from Everyday Rails, book picks, and other thoughts and ideas that didn't quite fit here.

Black lives matter.

I stand with the Black community against systemic racism, police violence and brutality, intolerance, and hate in the United States and worldwide. We must all demand better from our leaders, and ourselves. Stop tolerating intolerance.

While you're here, please consider making a donation to Black Girls CODE, who do great, important work to provide opportunity to underprivileged girls interested in tech, or any organization working toward equity and safety for all, not just the privileged. Thank you.

Test with confidence!

If you liked my series on practical advice for adding reliable tests to your Rails apps, check out the expanded ebook version. Lots of additional, exclusive content and a complete sample Rails application.

Newsletter

Ruby on Rails news and tips, and other ideas and surprises from Aaron at Everyday Rails. Delivered to your inbox on no particular set schedule.