How to test print stylesheets with Cucumber and Capybara

A print stylesheet is easy to create. Choose a font suited for paper, hide some elements, done. Unfortunately print stylesheets often break as the application is developed further, because they are quickly forgotten and nobody bothers to check if their change breaks the print stylesheet.

This card describes how to write a simple Cucumber feature that tests some aspects of a print stylesheets. This way, the requirement of having a print stylesheet is manifested in your tests and cannot be inadvertedly removed from the code.

Our example —…

External content

Flat Icons & Icon Fonts | CSS-Tricks

Nice list of icon sets that come in the form of fonts.

I recommend Font Awesome.

Impressumspflicht bei Facebook & Twitter: Schnelle Info und Abhilfe

Jedes nicht rein private Profil auf Social Media Portalen muss ein Impressum haben, das heißt insbesondere Unternehmen und Freiberufler (§ 5 Abs.1 TMG). Wer das Impressum dort nicht unter einem eigene Button mit der Aufschrift “Impressum” oder “Kontakt” unterbringt, bietet eine große Angriffsfläche für Abmahner (Quelle:

Hier also in kurzen Schritten, wie man ein Impressum erstellt und wie man es bei Facebook und Twitter einbindet:

#1. Impressum erstellen


SSL certificate problem, when trying to install the libyaml package

I was experiencing the following problem:

 It seems your ruby installation is missing psych (for YAML output). 
 To eliminate this warning, please install libyaml and reinstall your ruby

So I tried to install the libyaml package via:

rvm pkg install libyaml

This is when I experienced the SSL certification problem mentioned above. This happens when your RVM certificates have expired. You can fix this by updating them via:

 rvm get stable

After doing that curl could verify the SSL certificate and I w…

Understanding the Selenium error "Modal Dialog Present"

So your Cucumber feature sometimes dies with this exception:

Modal Dialog Present (Selenium::WebDriver::Error::UnhandledAlertError)

As a seasoned Selenium vetaran you are used to misleading error messages. Hence you might be surprised that the reason for this particular error is that there is actually a modal dialog present and preventing Selenium from executing commands like click or page.have_css?.

How your code triggers this issue

The reason why a dialog is shown is somewhat fucked …

Reset mysql root password

Stop the MySQL Server.

sudo /etc/init.d/mysql stop

Start the mysqld configuration.

sudo mysqld --skip-grant-tables &

Login to MySQL as root.

mysql -u root mysql

Replace YOURNEWPASSWORD with your new password!


  • If you have the error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  • If you have the error ERROR 2002 (HY000): Can't connect to local MySQL server through sock…

How to install GNOME classic desktop in ubuntu 12.04


sudo apt-get install gnome-session-fallback

or (alias)

sudo apt-get install gnome-panel

from a terminal.
Then logout to reach the logon screen and click on the options button next to you name.
Select Gnome Classic, log in et voilà.

Scoping a sunspot solr search by text using a string field

Assuming the following sunspot setup of the post class:

class Post < ActiveRecord::Base
  searchable do
    text :title
    string :state
    integer :category_ids

In Sunspot you can scope your search via the with method. It allows you to do stuff like: {
  fulltext "your query", :fields => :title

If you want to scope your search based on a text field, you have to add another field of the type string (such as the state fi…

How to inspect controller filter chains in specs

Sometimes you need to look at the filter chain in specs. You can do it like that on Rails 2:

Note that we need to look at the controller's class since before_filter and after_filter stuff happens on the class level.

Also mind that the above code will give you all filters, both those run before and after an action. You can query before? and after? on the filter objects to scope down to only some of them:

For Rails 3, …

How to fix: Firefox uses incorrect fonts on all webpages, regardless of their CSS

If you encounter a Firefox that does not care about your font settings but always uses specific fonts, you can fix that. Usually this should not happen, as it's not a default setting:

  1. Open up the Preferences.
  2. Switch to "Content".
  3. In the "Fonts & Colors" section, click the "Advanced…" button.
  4. Tick "Allow pages to choose their own fonts, instead of my selection above".
  5. Confirm by pressing "OK".
External content

Rails, callbacks, workers, and the race you never expected to lose « Logical Friday

How delayed jobs can make your after_save callbacks execute before the record is saved.

Be careful when using Unicode symbols for graphical elements

There are many fun Unicode characters like ▲ or ☯. You might be tempted to use them for graphical elements in lieu for an image. After all they are so much easier to style and scale than a raster image!

Unfortunately you will discover that these symbols render very differently on Linux, Windows and MacOS. The reason for this is that the font you are using will probably not contain any characters outside the standard Latin-1 set. When browsers encounter a character not included in the current font, they use a fallback font for this one cha…

RSpec and Cucumber: Shorthand syntax to run multiple line numbers in the same file

This works in modern RSpecs (RSpec >= 2.x) and Cucumbers:

rspec spec/models/node_spec.rb:294:322
cucumber features/nodes.feature:543:563:579

Also your features should be shorter than that :)

Git: When committing, check the diff

When committing, you should always check the diff of your changes so you don't include any leftovers or irrelevant/bad changes. Any time spent on that is well invested as it saves you rejected merge requests or any mess you need to clean up later.

While you can just use git diff or git diff --cached (to diff staged changes), you can also have Git include the changes as a comment below the commit message:

git commit -v

That will open up the usual commit "file" in your preferred text editor, but it will include a diff below the s…

External content


Methods to remove e.g. order or conditions from an existing scope chain.

Rspec shared example group error: ensure_shared_example_group_name_not_taken

Never name your shared example group *_spec.rb. Otherwise rspec will try to load your example group as a spec and you will get the error above.

3209 cards