Tag: ruby

• Stupid Ruby Tricks: Arrays

July 24, 2019

If you want a Ruby array with "hard" boundaries, use Array#fetch instead of Array#[]

• Functional Programming in Ruby

July 21, 2019

A functional programming riff on a common coding test.

• Live Refactoring

April 28, 2019

I "live" tweeted a refactoring session.

• Using Ruby Enumerators for Resumable Iterators

March 11, 2018

Here's a power technique: You can use Ruby Enumerators to create "resumable" iterators when you're extracting data from the application console.

• Speed Up Your Integration Tests with a Jig

February 7, 2014

If you've written enough integration tests (with Capybara et al.), you must have noticed how much time your tests spend just logging into your web app. Even if it takes 1 second each time, it starts to add up. Here's a solution that I've written several times, now. I create a test "jig" that allows me to authenticate into my application with a single visit.

• method_missing Hazardous to Your Module?

February 22, 2013

We built an(other) object factory module for our current project and it looks a lot like all the others: After a while, we noticed that the create methods were all exactly the same. Time for some dynamic refactoring!

• TDD Action Caching in Rails 3

March 28, 2012

On my current project, we needed to prove that an action cache was working as expected. Alas, the blogosphere had either out-of-date or unhelpful information. So, after many experiments, we came up with an RSpec test that does what we want. It seems ugly to me, and I hope there's a better way. The names have been changed to protect the guilty. Any resemblances to actual classes and methods are purely coincidental.

ruby - Ken Mayer