Rails views, internationalization, special characters, and testing with Rspec
The problem
File this under small problems that take more time than they should to solve, and I couldn’t find an answer with a web search.
Let’s use a simple example. If you have text like this in your translation file (e.g. en.yml):
users:
new:
header: "Let's go!"
And then show it in a view template (e.g. app/views/users/new.html.erb):
<h3><%= t('.header') %></h3>
And then try to match it in an Rspec test, you’ll get an error that it couldn’t be found:
expect(response.body).to include(I18n.t('users.new.header'))
Failure/Error: expected "[...]Let's go![...]" to include "Let's go!"
Rspec with Rails 7 and System Tests
Hello world! It’s time for my first post in over 4 years.
I recently set up a new Rails 7 project with Rspec and looked online for tips, as one does. I’ve set up many Rails projects before, but not yet with Rails 7, and it’s been a while. The top result in Google for “rails 7 with rspec” is currently Adrian Valenzuela’s Setup RSpec on a fresh Rails 7 project. His post was really helpful for me shaking off the rust. So rather than writing another post that’s 80% the same, I’ll just share a few additional tips. Think of this post as a companion piece to Valenzuela’s.
Terry Toppa, 1939-2021: a remembrance of my father
My father passed away on May 10 last year, after a short and unexpected battle with cancer (aside from some back pain, he was doing fine just a few weeks earlier). I wrote his obituary the next day. There was a short graveside committal service, where I also had the opportunity to say a few words about him. I want to share those words here, and his obituary. Two days ago, March 10, he would have been 83.
“Magic: The Gathering” Standard deck brew – Jeskai Pirate Aggro
This is my first post about Magic: The Gathering, which I’ve been playing for years. If you have no idea what I’m talking about, I highly recommend this New Yorker article about the history and culture of the game or if you prefer audio, this episode of Planet Money from NPR, about how the game has managed to stay popular for over 25 years.
Ever since Rivals of Ixalan came out about a year ago, Path of Mettle has been my favorite card to try to build around. It’s a finicky card that requires your deck to be stacked with the specific types of creatures it needs, but the payoff is that, once transformed into Metzali, Tower of Triumph, it’s “a one-card, synergistic game-ender,” as Craig Krempels put it. I can’t resist trying to make a card like that work. You see Field of Ruin rarely these days, Teferi, Hero of Dominaria can’t touch it, and it can take down a Carnage Tyrant (since its ability doesn’t target). The one damage spread across the board by Path of Mettle entering the battlefield is also highly relevant in the current metagame, with a lot of one toughness creatures running around in mono-blue, white aggro, and token decks (it also hits Llanowar Elves in Sultai and Pteramander in Drakes). Of course the trick is, any competitive deck can’t rely on one card – you still need to be able to win without it, and I’ve been getting good results with this build, which I’ve been iterating on for a while.
Ad for Sugar in 1966 Issue of Time
In 1995 I photocopied this ad from a 1966 issue of Time magazine. I was in grad school doing some research on the Vietnam war, and couldn’t help but notice it. It’s almost as over the top as the old Saturday Night Live fake ad for speed. I thought I lost the photocopy years ago, but found it in a box in my basement the other day.
If you can’t make out the “Note to Mothers” at the bottom, it says:
Note to Mothers: Exhaustion may be dangerous – especially to children who haven’t learned to avoid it by pacing themselves. Exhaustion opens the door a little wider to the bugs and ailments that are always lying in wait. Sugar puts back energy fast – offsets exhaustion. Synthetic sweeteners put back nothing. Energy is the first requirement of life. Play safe with your young ones – make sure they get sugar every day.
RubyConf 2018 is about to start, so let’s talk about RubyConf 2017!
RubyConf 2018 starts tomorrow, and just like I did with RailsConf, I’m very belatedly going to share some highlights from RubyConf 2017, which was in New Orleans last November. It was my first time attending RubyConf, and what struck me the most was the really strong sense of community. Here’s what one first-time attendee had to say:
…This conference was so incredibly worth it. I learned about sweet gems, cool projects, and job opportunities. But more importantly, I met SO MANY totally epic and amazing individuals that even after only three short days I happily now consider friends. I cannot wait to follow their coding lives and journeys in the years to come. I am confident that so many of them are going to do great and groundbreaking things. Plus, I cannot WAIT for my next RubyConf.
That’s from the post 31 thoughts I had while attending my first #RubyConf as an Opportunity Scholar. RubyConf’s Opportunity Scholar program provides financial support for folks who wouldn’t be able to attend otherwise, and are getting started with Ruby. The Scholars are then each matched with a Guide – experienced people who can help them navigate the conference, and make connections for professional development and job opportunities. I applied to be a Guide for this year’s RubyConf and I was selected – I’m looking forward to it!
RubyConf has three tracks of talks, so it’s not possible to attend them all, but here are the ones that were my favorites, including links to the videos for each of them:
Watch Fish Story (フィッシュストーリー), Right Now
If you might like a movie that is equal parts…
- Memento: but instead of the story unfolding in reverse, it unfolds in a completely jumbled sequence, going from 2012, to 1982, to 2009, to 1975, and then back to 2012. If you enjoy a movie that calls for your active mental participation, and you appreciate the movie maker’s attention to detail in making all the seemingly disparate threads of a story mesh together, then Fish Story is for you.
- Anvil! The Story of Anvil: except instead of a story about a briefly famous band that falls into obscurity, the band in this story, Gekirin, goes from obscurity to oblivion. They write a punk song in 1975 that is ahead of its time, that almost no one appreciates, but ultimately is the key to saving the world (yes, punk rock can save the world, and fortunately, they actually wrote a great track for the movie).
- Armageddon: in 2012, the destruction of life on earth by asteroid is imminent. Last ditch attempts to save humanity, involving space ships and nuclear warheads, are involved. If you’re wondering what a forgotten punk rock song from the 70s has to do with saving the earth from an asteroid 37 years later, well you’ll just have to watch the movie!
- The Karate Kid and Power Rangers: a young man who isn’t sure why his father forced him to endlessly practice martial arts as a child finally finds his purpose.
- High Fidelity: the cool record store owner in this movie has the same encyclopedic knowledge of music as John Cusack’s character, but his sadness does not come from girl troubles.
- If You Give a Pig a Pancake (which is a children’s book, not a movie): after watching Fish Story, you might start thinking about causality, conditionality, and contingencies, but all I could think of was this book. Each step in the story makes sense by itself, but they all add up to a crazy spectrum of events.
…then you will enjoy Fish Story.
One Day in Tokyo: Asakusa, and a River Cruise to Odaiba
If you have the misfortune of visiting Tokyo for only a few days, you’ll find it hard to decide where to spend your time in a city that has so many amazing things to see and do. A good way to get a sense of the traditional, slower-paced Tokyo, as well as the modern, fast-paced Tokyo in a single day is to venture to the northeastern district of Asakusa in the morning, with its temples and buildings dating back to the 1950s (Tokyo was essentially leveled in the WWII fire-bombings, so the 50s is considered old for Tokyo architecture). Then take a cruise south on the Sumida river, which will take you under about a dozen architecturally distinct bridges. The cruise ends on the man-made island of Odaiba in Tokyo Bay, which offers endless attractions for modern shopping and hi-tech fun, and even a sandy beach. At the end of the day (or night), head back to the mainland on the Yurikamone line, which does an entirely gratuitous 360° loop as it crosses the river, giving you a panoramic view of eastern Tokyo.
RailsConf 2017 in tweets, and my “Why Do Planes Crash?” lightning talk
RailsConf 2018 starts in exactly one month, and I’m looking forward to it! This means I should probably get around to saying something about RailsConf 2017. The video above is cued to start at the beginning of a lightning talk I gave. The title was “Why Do Planes Crash? Lessons for Junior and Senior Developers.” Analyses of plane crashes show planes actually crash more often when the senior pilot is in the flying seat, often because junior pilots are reticent to speak up when they see problems, while senior pilots don’t hesitate to do so when the junior pilot is flying. There are some great lessons developers can apply from this for how to do mentoring and pair programming.
The lightning talks were at the end of the 2nd day, and I made a last minute decision that morning to sign up and put a talk together. I’ve given a number of conference talks before, but never to a crowd this big, and never with so little time to prepare. Then when it was time to give the talk, there was a technical issue that prevented me from seeing my notes, so I had to wing it. Under the circumstances I think it still turned out ok. Here are my slides (they’re also embedded below) and some tweets about the talk:
Japanese Baseball on the 4th of July
As an American attending a Japanese major league baseball game for the first time, it turned out that the most fun part wasn’t watching the game, it was enjoying the highly choreographed, non-stop cacophony of alcohol soaked cheering and singing from the fans. The game itself was good, and was very much like watching two good major league American teams play. It was the Yomiuri Giants vs. the Hanshin Tigers, who have a long-running rivalry like the Yankees and Red Sox. The big difference from American baseball is the rituals the Japanese bring to the game. When you combine Japanese baseball fanaticism with their obsessions over convenience, cleanliness, and group activities involving alcohol, you get a unique experience.






