Angular isolate scopes: Calling a parent scope function with externally defined arguments

Isolate scopes offer three kinds of variable binding. One of them is &, allowing to bind a property of the isolate scope to a function in the parent scope. Example:

<panel proxy="parent.someFunction(arg1, arg2)"></div>

# Coffeescript
@app.directive 'panel', ->
    parentFn: '&proxy'
  link: (scope) ->
    scope.parentFn(arg1: 'first', arg2: 'second')

In this dumb example, the panel directive will call its scope's parentFn() function with two arguments, which proxies to parent.someFunction('first', 'second')

Linux: Find out which processes are swapped out

Processes in Linux might be put into Swap ("virtual memory") occasionally.
Even parts of a single process might be removed from memory and put into Swap.

In order to find out which processes remain within Swap, run this:

sudo grep VmSwap /proc/*/status | egrep -v "0 kB"

Keep in mind Swap is not evil by definition. Some bytes per process beeing put to Swap will not have that much of performance influence.

If you want the Linux virtual memory manager (which is responsible for the decision if and which processes are moved to Swap) to be…

Hack of the day: One-liner to run all Cucumber features matching a given string

The following will search for all .feature files containing a search term and run them using geordi.

find features/ -name '*.feature' | xargs grep -li 'YOUR SEARCH TERM' | sort -u | tr '\n' ' ' | xargs geordi cucumber

If you do not use Geordi, xargs cucumber or similar might work for you.

For details about each command, see [](*.feature%27+%7C+xargs+grep+-li+%27YOUR+SEARCH+TERM%27+%7C+sort+-u+%7C+tr+%27%5Cn%27+%2…

How to find disabled fields with Capybara

At least Selenium cannot find disabled fields. Unless you find them explicitly:

find_field 'This is disabled', disabled: true

How to inspect RSS feeds with Spreewald, XPath, and Selenium

Spreewald gives you the <step> within <selector> meta step that will constrain page inspection to a given scope.

Unfortunately, this does not work with RSS feeds, as they're XML documents and not valid when viewed from Capybara's internal browser (e.g. a <link> tag cannot have content in HTML).

Inspecting XML

If you're inspecting XML that is invalid in HTML, you need to inspect the page source instead of the DOM. You may use Spreewald's "… in the HTML" meta step, or add this proxy step fo…

How to change the hostname in Cucumber features

Capybara uses as the default hostname when making requests.
If your application does something specific on certain hostnames and you want to test this in a feature, you need to tell Capybara to assume a different host.

Given /^our host is "([^\"]+)"$/ do |host|
  page.config.stub app_host: "http://#{host}"
  # In older Capybaras (< 2.15) you needed to do this instead:
  Capybara.stub app_host: "http://#{host}"

You can now say:

When I go to the start page
Then I should not see "Home ...
Linked content

How to preview an image before uploading it

When building a form with a file select field, you may want to offer your users a live preview before they upload the file to the server.

HTML5 via jQuery

Luckily, HTML5 has simple support for this. Just create an object URL and set it on an <img> tag's src attribute:

$('img').attr('src', URL.createObjectURL(this.files[0]))

Unpoly Compiler

As an Unpoly compiler, it looks like this:

up.compiler '[image_p…

How to use triple quotes inside a Cucumber docstring

Cucumber's docstrings let you add long strings to a step like this:

# foo.feature
Given this text:
First line
Second line

Second Paragraph

# foo_steps.rb
Given /^this text:$/ |docstring|
  puts docstring.split

You see these neat triple double quotes ("""). Now what to do when you need your docstring to contain triple double quotes, too?

# Does not work:
Given this text:
Docstrings work like this:
  Docstring example
You see?

Update: Official solution

You can escape the inner quotes …

Test e-mail dispatch in Cucumber

Spreewald has steps that let you test that e-mails have been sent, using arbitrary conditions in any combination.

The attached file is for legacy purposes only.

How to fix routing error when using concerns in Rails up to


  • Don't write resources :people, :concerns => :trashable
  • Write

    resources :people do
      concerns :trashable


Writing a controller spec I encountered this error:

Failure/Error: get :index
  No route matches {:controller=>"people"}

caused by this route definition

resources :people, :concerns => :trashable

which renders strange routes:

trash_person PUT /people/:id/trash(.:format) people#check {:concerns=>:trashable}

Find the innermost DOM element that contains a given string

Let's say you want to find the element with the text hello in the following DOM tree:


You might think of using jQuery's :contains selector:


Unfortunately that returns a lot more elements than you expect:

[ <html>...<html>,
  <strong>hello</strong> ]

The reason for this is that…

Geordi 1.3 released


  • Geordi is now (partially) tested with Cucumber. Yay!
  • geordi cucumber supports a new @solo tag. Scenarios tagged with @solo will be excluded from parallel runs, and run sequentially in a second run
  • Support for Capistrano 2 AND 3 (will deploy without :migrations on Capistrano 3)
  • Now requires a .firefox-version file to set up a test firefox. By default now uses the system Firefox/a test Chrome/whatever and doesn't print warnings any more.
  • geordi deploy --no-migrations (aliased -M): Deploy with `cap …
Linked content

Geordi 1.2 released


  • Remove some old binaries (commands still exist in geordi) and mark others as deprecated
  • Rewrite deploy command to support most deploy scenarios:
    • master to production
    • feature branch to staging
    • master to staging or production to production (plain deploy)
  • Improve Cucumber command (fixes #18):
    • Fix pass-through of unknown options to Cucumber
    • Add –rerun=N option to rerun failed Cucumber tests up to N times. Reboots the test environment between runs, thus will pick up fixes you made durin…

How to open a new tab with Selenium

Until recently, you could open a new tab via when using execute_script in Selenium tests. It no longer works in Chrome (will show a "popup blocked" notification).

This is because browsers usually block unless the user interacted with an element for security reasons. I am not sure why it did work via Selenium before.

Here is an approach that will insert a link into the page, and have Selenium click it:

path = "/your/path/here"
id = "helper_#{SecureRandom.hex(8)}"
execute_script <<-JAVASCRIPT

Make nokogiri >=1.6.0 use system libxml2

Quick check: bin/rails runner 'puts'

Step by step instruction

Nokogiri uses vendored libxml2 since version 1.6.0, which means that each time a new issue with libxml2 occurs, you have to update nokogiri itself. Another approach is to use the system lib again, as it patches the libxml2 library with periodically system updates.

  1. bundle config --local build.nokogiri --use-system-libraries
  2. Ensure that .bundle is not gitignored and .bundle/config contains these lines:

``` …

Linked content

RSpec & Devise: How to sign in users in request specs

You know that Devise offers RSpec test helpers for controller specs. However, in request specs, they will not work.

Here is a solution for request specs, adapted from the Devise wiki. We will simply use Warden's test helpers – you probably already load them for your Cucumber tests.

First, we define sign_in and sign_out methods. These will behave just like …

Geordi: Running headless Selenium tests

Geordi now supports our solution for running Selenium tests without having Firefox windows popping up all over your workspace.

This will stop Selenium windows from appearing on your desktop, but you can still inspect them when necessary.


Update geordi with gem install geordi.

Run geordi vnc --setup and follow the instructions.


geordi cucumber will automatically use VNC. Launchy will still open pages in the usual place.

geordi vnc will allow you to in…

You can now override all Spreewald steps with more specific versions

You can now define this step without Cucumber raising Cucumber::Ambiguous:

Then /^I should see "whatever I want"$/ do

This is available in Spreewald 1.5.0+.

This website uses cookies to improve usability and analyze traffic.
Accept or learn more