Weeknotes 9
29th August, 2021
“Testing tests and Electron drama”
-
ActionMailer has a feature called interceptors. It allows you to make modifications to an email before it’s delivered and I had the perfect use-case, to override the email recipient depending on various factors such as environment. It solved my problem quickly and provides a nice, de-coupled, way to hook into ActionMailer. Not deployed to production yet, but recommended regardless.
-
Writing tests gives me confidence in the code I’m producing. Struggling with test frameworks does not. Sadly there was a fair bit of the latter this week figuring out why RSpec Request specs where not performing jobs automatically as they should when the ActiveJob queue adaptor is set to
:inline
.My problem sounds like this Rails issue. During request specs the queue adapter is reset to
:test
which means that jobs are not performed automatically.I didn’t completely fix the issue, and the potential fix of upgrading Rails was too much to do at the time, but I did work around it by writing a custom RSpec matcher. A lot of time was wasted that I could have spent on writing tests though.
-
There was an interesting discussion about Electron on ATP 444. It was prompted by 1Password’s move to Electron, especially in relation to macOS. I myself was worried about this move, but as the hosts of ATP discussed, the situation is more nuanced than it first appears.
I’m conflicted. As someone with web development skills but no “native” app skills (save for some messing about with Objective-C and Cocoa years ago) Electron is appealing to me, but I also miss the native feel of apps that can be lost when using Electron.
I think it probably makes a lot of sense for some companies to use it. I’m sure it would mean the difference between having a native app available for a platform and not at all in many cases, but you’d have to be mindful of the trade-offs involved. There is a danger that you end up creating an app that is not fit for the platform on which it runs.