Millo's Musings

Make Capybara Raise, Not Warn, When It Detects Unused Parameters

I love Capybara but it has one little snag that keeps tripping me up. Have a look at the following RSpec code and see if you can spot the problem:


One Quick Trick to Make RSpec Play More Nicely

When you run the rspec command without specifying a particular file or group of files that contains your specs, it assumes that your specs live in the spec directory. (You can override this default with the –default-path option, although I’m not sure why you’d want to.)


Searching By Multiple Columns with ActiveRecord and PostgreSQL

My Rails app has a model called Account, and I’ve been tasked with implementing an account search feature. Users type their search query into a form and see a list of accounts which match that query. The problem is that exactly what constitutes a ‘match’ is complicated. Each Account has multiple attributes (email, first_name etc.) which could match the search query, and even some associated models (e.g. an account has_many :phone_numbers) whose attributes should be searchable too.