Git: How to get a useful diff when renaming files
tldr; Use git diff -M or git diff --find-renames when you've moved a few files around. Usage
How to load an SQL dump from a migration
If you want to load an SQL dump from an ActiveRecord migration, you might find this to be harder than...
RSpec: Only stub a method when a particular argument is passed
To only stub a method call if a given argument is used, but use the default implementation for other arguments...
Geordi 1.0 released
Geordi 1.0 features a command line application geordi, that holds most of Geordi's previous commands. New features
How to set up database_cleaner for Rails with Cucumber and RSpec
Add gem 'database_cleaner' to your Gemfile. Then: Cucumber & Rails 3+ # features/support/database_cleaner.rb DatabaseCleaner.clean_with(:deletion) # clean once, now DatabaseCleaner.strategy = :transaction...
How to circumvent Firefox's "Document expired" page in Selenium tests
When navigating back to a page that was received from a POST request, undesired side effects may happen. Therefore, modern...
Jasmine 2 cheat sheet for RSpec lamers
In the tradition of our PostgreSQL cheat sheet for MySQL lamers, here is a cheat sheet for Jasmine when you...
Jasmine: Testing AJAX calls that manipulate the DOM
Here is a Javascript function reloadUsers() that fetches a HTML snippet from the server using AJAX and replaces the current...
Jasmine: Reset the location when testing code that uses pushState / replaceState
When testing code that uses pushState / replaceState, your browser will appear to navigate away from http://localhost:3000/specs (or wherever...
AngularJS: Binding to Perl-style getter/setters functions
Angular 1.3+ has an alternative getter/setter pattern: You can bind ng-model to an accessor function. This is a function...
Getter and setter functions for JavaScript properties
JavaScript objects can have getter and setter functions that are called when a property is read from or written to...
Testing focus/blur events with Cucumber
This is a problem when using Selenium with Firefox. We recommend using ChromeDriver for your Selenium tests. This setup allows...
Taking screenshots in Capybara
Capybara-screenshot can automatically save screenshots and the HTML for failed Capybara tests in Cucumber, RSpec or Minitest. Requires Capybara...
Action Mailer Previews
Rails includes a way to see what an e-mail will look like. Integration to RSpec All you need to...
The developer console can do more than you think!
You can do so much more than console.log(...)! See the attached link for a great breakdown of what the developer...
Active Record and PostgreSQL — Ruby on Rails Guides
Rails guide that covers PostgreSQL-specific column types and usages for Active Record. You should especially keep in mind the...
Reading an element's attributes with Capybara
capybara_element['attribute_name'] allows accessing an element's attributes in Capybara. A few examples: find('#my_element')['class']
Cucumber: Removing uploaded files after test runs
Cucumber will clean up files you've uploaded in your Cucumber features automatically with the attached code. Put the file...
RSpec matcher "be_sorted"
RSpec::Matchers.define :be_naturally_sorted do match do |array| array == array.natural_sort end end See RSpec: Where to put custom...
Cucumber step to test whether a select field is sorted
This step will pass if the specified select is sorted. Then /^the "(.*?)" select should be sorted$/ do |label, negate|
Fixing the warning Time#succ is obsolete; use time + 1
Chances are you're seeing the warning repeated a lot of times, maybe thousands of times. Here's how to...
How to emulate simple classes with plain JavaScript
If you want a class-like construct in JavaScript, you can use the module pattern below. The module pattern gives...
AngularJS: How to remove a watch
Sometimes you want Angular to watch an object only until a certain state is reached (e.g. an object appears in...