Don't Test Like That!

As a consultant, I come across a lot of bad test suites in Rails and JavaScript apps. The following are all RSpec, Jest, or Jasmine tests that I have found in the wild – with minor changes for clarity or to protect the guilty :) (myself included!) These are some simple things not to do, along with some advice about what to do to accomplish the same goal. Don’t test internals in a system test System »

JSON API Helpers for API Testing in Rails using Airborne

Update 05/08/2017 I made a gem! https://github.com/Ross-Hunter/jsonapi_expectations I am a huge fan of the Airborne gem for testing APIs. Airborne uses rest_client to make HTTP requests and provides the following properties for use in your tests. response - The HTTP response returned from the request headers - A symbolized hash of the response headers returned by the request body - The raw HTTP »

Index Your Foreign Keys

We add indexes to our database in order to speed up read operations. Basically, an index is a sorted copy of a particular set of columns the database uses to quickly look up the attributes of another table, most commonly, foreign keys of relations. There are several ways this can actually be implemented on the database; essentially, we tell the database which values we’ll be looking up most often and »

ActiveRecord Associations & You

I love abstraction. It’s great to compartmentalize complexity and keep your application modular. SQL is not that. Relying on SQL strings in your code ties your implementation directly to the type, structure, and even the version of your database. ActiveRecord (the ORM behind Rails) is great for letting us focus on our application and not worry so much about the database particulars. However, understanding »

Better Rails Debugging with better_errors and jazz_hands

Go beyond the stacktrace with 2 gems that grant you debugging superpowers. Better Errors Does this screen look familiar? Do you notice anything wrong with this picture? That is correct, that is the default Rails error page and you are absolutely right, it is completely hideous and hurts to look at. It is begging to be improved. By answering these questions you have already proven yourself to »