My talk at Boston.rb about Rails::Engines.
One problem that you can run into when implementing a Rails Engine is hit or miss third party library support. Even when a library does support engines (i.e. RSpec), because few people code in the context of them, documentation and online support can be few and far between. When trying to test my mounted and isolated engine’s routes I quickly realized RSpec would produce failures because it was loading my main app’s routes into the tests instead of my engine’s. It seemed like it should be an easy fix but none of the solutions I found online worked.
Only after a “bundle show rspec-rails” and diving into the code did I find the very easy but non-obvious hook that fixed everything. Turns out this hook was only added recently to routing tests, is being added to controller tests as we speak, and documentation is certainly light. To set the routes used in Routing Tests (and soon Controller tests) use this public API:
I’m a huge fan of Slim Templates. I admit I always liked the idea of HAML, but when I was told that the cognitive load of using HAML was a small but unnecessary burden on front-end developers, I felt like a whiny kid who couldn’t play with his new toy. ”But HAML takes minutes to learn! How could something so easy, slow someone down?” I’d think to myself.
With Slim Templates I believe you have no excuses left. Slim is so close to HTML it’s absurd. Plus the benefits you get of terseness and forced structure are huge, especially in a team setting. Check out the comparison I made here where a snippet of ERB was converted to Slim by removing elements (in red) and adding elements (in green).