RSpec: How to get a full backtrace

Posted Over 9 years ago by Thomas Klemm.

Git: How to get a useful diff when renaming files

Posted Over 9 years ago by Thomas Klemm.

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

Posted Over 9 years ago by Henning Koch.

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

Posted Over 9 years ago by Henning Koch.
relishapp.com

To only stub a method call if a given argument is used, but use the default implementation for other arguments...

Geordi 1.0 released

Posted Over 9 years ago by Dominik Schöler.
github.com

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

Posted Over 9 years ago by Dominik Schöler.

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

Posted Over 9 years ago by Dominik Schöler.

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

Posted Over 9 years ago by Henning Koch.

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

Posted Over 9 years ago by Henning Koch.

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

Posted Over 9 years ago by Henning Koch.

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

Posted Over 9 years ago by Henning Koch.

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

Posted Over 9 years ago by Henning Koch.

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

Posted Over 9 years ago by Dominik Schöler.

This is a problem when using Selenium with Firefox. We recommend using ChromeDriver for your Selenium tests. This setup allows...

Taking screenshots in Capybara

Posted Over 9 years ago by Thomas Klemm.
github.com

Capybara-screenshot can automatically save screenshots and the HTML for failed Capybara tests in Cucumber, RSpec or Minitest. Requires Capybara...

Action Mailer Previews

Posted Over 9 years ago.
api.rubyonrails.org

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!

Posted Over 9 years ago by Henning Koch.
developer.mozilla.org

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

Posted Over 9 years ago by Arne Hartherz.
edgeguides.rubyonrails.org

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

Posted Over 9 years ago by Thomas Klemm.

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

Posted Over 9 years ago by Thomas Klemm.

Cucumber will clean up files you've uploaded in your Cucumber features automatically with the attached code. Put the file...

RSpec matcher "be_sorted"

Posted Over 9 years ago by Dominik Schöler.

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

Posted Over 9 years ago by Dominik Schöler.

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

Posted Over 9 years ago.
makandracards.com

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

Posted Over 9 years ago.

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

Posted Over 9 years ago by Arne Hartherz.

Sometimes you want Angular to watch an object only until a certain state is reached (e.g. an object appears in...