Part of a short sequence of posts about various testing practices. They could be used as pointers in pull request reviews. Most modern testing frameworks strive for terseness and minimization of boilerplate (thankfully). However, I find RSpec (and copycats ) in a league of its own in terms of expressivity, elegance, and (unfortunately) the number of ways to skin those cats. For example, it is easy…
I like Gary Bernhardt. In fact, he might be my idol. He had original ideas and presented them very well. I learned a lot from his teachings. Watch this 2012 talk please , it is well worth it. In short, he listed several technologies that upon their release either “allowed saying new things” (capable) or “made innovations accessible for the industry” (suitable). According to him, LISP, C++, Ruby…
Part of a short sequence of posts about various testing practices. They could be used as pointers in pull request reviews. Here's an assortment of test description examples I come across too often: it( "imports records successfully" , () => { @Test public void testParsesInputCorrectly () { context "when parsing malformed input" do it "does the right thing" do def test_works (): This last one is my…
I have written about running one Rails test quickly . To streamline the red-green-refactor cycle, the red or green should happen automatically, quickly, and be close to my eye focus point but not obstruct it. vim-test solves the "automatically" part. A shortcut to clear the terminal and run the current test somewhere. A shortcut to run all tests in the current file. A shortcut to run all tests. It…
I had an interview for a Ruby developer position. As part of a live Rails coding session a class performing operations needed refactoring into supporting services. Let's say the logic in question is query = 'troglodytes troglodytes' response = URI . open( "https://xeno-canto.org/api/2/recordings?query=#{ CGI . escape(query) }" ) if response . status [ 0 ] == '200' body = JSON . load(response) ...…
FZF is fantastic! Well , of course it is. But it continues to amaze me how much mileage one can get from such a simple idea: a list selector that consumes stdin and prints to stdout. At some point I hacked together an FZF-based workflow to work with kubectl . In retrospect, kubectl-fzf might have done the job. But my workflow ended up very specific and ergonomic. The setup Let's not use the actual…
Typically I write code test-first, TDD style. I tend to run specs very often, before and after changes, even trivial ones. That's a lot of test runs. When working on Rails apps waiting even a second gets very annoying very fast. Rails had some workarounds like zeus and, later, spring . They are great: they preload the Rails app and then fork the process (or do some other magic) so that your specs…
This method of printing text to bash input is so good it is worth repeating. Say you'd like to produce a kind of auto-completion tool to help you input complex bash commands. You could write a script to run your command. But in some cases the command to run is a complex pipeline that you start with and then continue tweaking and running. It's easier to generate the command, print it to the…