Click on a piece of text in Cucumber / Capyabra

The step definition below lets you write:

When I click on "Foo"

This is useful in Selenium features where the element you click on is not necessarily a link or button, but could be any HTML element with a Javascript event binding.

The easiest way to get this step is to use Spreewald. If you would like to add it manually, here is the step definition:

When /^I click on "([^\"]+)"$/ do |text|
  matcher = ['*', { :text => text }]
  element = page.find(:css, *matcher)
  while be...

New cards feature: Explicit language declaration for syntax highlighting

Makandra cards will auto-detect the language used for syntax highlighting.

This auto-detection sometimes fails for short code snippets. In such cases you can explicitly declare the language for Github-style code blocks:

body {
  font-size: 12px

Will turn into this:

body {
  font-size: 12px

To disable syntax highlighting entirely use the text language:

I am nothing without pretend ...

How to: Limit or disable textarea resizing in Chrome and Firefox

Consider this Sass:

  width: 320px;
  height: 240px;

Any textarea with the comment class will be sized 320 by 240 pixels. In WebKit browsers (Chrome, Safari, …) or Firefox, this is only the initial size – users can resize textareas to become bigger.

This is helpful to the user, but may be breaking your application layout in some cases.

If you want to disable it, don't introduce any proprietary CSS properties. Instead, set maximum width and/or height to the values of width and height:


Run specific version of bundler

You want to run a specific, maybe older version of bundler for whatever reason?

$ bundle _1.0.21_ -v
Bundler version 1.0.21
External content

Ruby 1.8.7-p370 released

It's the last bugfix release. We will get another year of security fixes, then no more patches.

Err [...] 404 Not Found [IP: 80]

I've got often this error on just one server:

Err precise/universe amd64 Packages
404  Not Found [IP: 80]

But there was no problem with the network connection or the server.

After I deleted the local lists cache with rm -r /var/lib/apt/lists it works again.

Speed up large Cucumber test suites

Note: The information is this card is ancient and probably no longer accurate.

Test suites usually grow over time as more and more development time is spent on a projects. Overall run-time and performance of Cucumber suites in turn increases, too.

You can use the very same way Henning suggested for speeding up RSpec some time ago.

Put the following into features/support/deferred_garbage_collection.rb

Before do

Bundler: Fatal error and 'no such file to load -- net/https'

Today, I ran into trouble on a fairly fresh installed VM, running Ubuntu. I tried to bundle install and got this stacktrace:

Fetching gem metadata from, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at Thanks!
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in gem_original_require': no such file to load -- net/https (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in require'
from /usr/li…

Nice way to call multiple steps from a step definition

Use %-notation:

Given /^I have an article in my cart$/ do
  steps %{
    And I go the article list
    And I open the first article
    And I press "Add to cart"

Rails 3.1 gives you free down migrations

In Rails 3.1+, instead of defining a separate up and down method you can define a single method change:

class AddComparisonFieldsToReport < ActiveRecord::Migration
  def change
    add_column :reports, :compare, :boolean
    update "UPDATE reports SET compare = #{quoted_false}"
    add_column :reports, :compare_start_date, :date
    add_column :reports, :compare_end_date, :date

Migrating up works as expected:

b rake db:migrate
== AddComparisonFieldsToReport: migrating ==================================== – ad…

Updated: Test a gem in multiple versions of Rails

Updated the card with our current best practice (shared app code and specs via symlinks).

Consul 0.3.0 has a shortcut to quickly create an action map for CRUD controllers

In moderately complex authorization scenarios you will often find yourself writing a map like this:

class NotesController < ApplicationController
  power :notes, :map => {
    [:edit, :update] => :updatable_notes
    [:new, :create] => :creatable_notes
    [:destroy] => :destroyable_notes

Because this pattern is so common, Consul now has a shortcut :crud to do the same:

class NotesController < ApplicationController
  power :crud => :notes

New cards feature: Personal RSS feed that includes public and private cards

Your account profile now links to a personal RSS feed. This RSS feed contains the newest public and private cards for all your decks.

When overwriting "method_missing", remember to overwrite "respond_to?" as well

When you use method_missing to have an object return something on a method call, always make sure you also redefine respond_to?.

If you don't do it, nothing will break at a first glance, but you will run into trouble eventually.

Consider this class:

class Dog
  def method_missing(method_name, *args, &block)
    if method_name == :bark

This will allow you to say:
=> "woof!"

But: :ba...

Install rabbitmq plugins (e.g. management plugin) on Ubuntu 12.04

If you want to install rabbitmq plugins on Ubuntu 12.04 you can do this with:


This binary is not in your default $PATH. Beause of this you have to give the full path.

Setup your terminal to not scroll when there is new output

When you are scrolling up to investigate a test failure it is super annoying when the terminal scrolls back down whenever the running test outputs another line. Luckily you can disable this behavior:

  • Gnome terminal: Edit -> Profile preferences -> Scrolling", uncheck *Scroll on output
  • Terminator: Right click on terminal screen, Preferences -> Profile -> (for each profile) -> Scrolling, uncheck Scroll on output

has_defaults is now a gem

  • has_defaults is now a gem, no longer a plugin.
  • The plugin version no longer exists. Note that plugins are no longer supported in 3.2.
  • If you are working on an application that has the plugin version of has_defaults there is no advantage to be gained from upgrading the gem. The gem is there for you should you one day upgrade to Rails 3.2+.
  • Please don't use the defaults gem which we original forked away from in 2009. It sets defaults when a field is `bl…

rake spec + rails_admin = weirdly failing specs

If you use rails_admin, your specs pass with the rspec binary, but not using rake spec (or rake parallel:spec etc), put this at the top of your spec_helper:


Don't ask.

This is probably also true for cucumber, your env.rb would be the right place.

3148 cards