Don't insert table rows in a Rails database migration. This will break tests that expect that database to be...

makandra dev

In order to go back one page in your Cucumber tests, you can use the following step definition for Capybara...

Plugins (and gems) are typically tested using a complete sample rails application that lives in the spec folder of the...

web.archive.org

This step tests whether a given select option comes preselected in the HTML. There is another step to test that...

This is non-trivial because you need to fake event objects and require different code for different browsers. Luckily, there...

This note describes a Cucumber step definition that lets you test whether or not a CSS selector is present on...

github.com

Sometimes you inherit a non Rails or non Rack based web app such as PHP, Perl, Java / JEE, etc. I...

github.com

The ancestry gem allows you to easily use tree structures in your Rails application. There is one somewhat unobvious pitfall...

Sometimes the order in which strings appear on a page matters to you. Spreewald gives you steps like these:

These steps are now part of Spreewald. This note describes a Cucumber step that lets you write this:

Both these approaches will keep your GET parameters -- and will only work for GET requests. Capybara: When /^I reload the...

youtube.com

power-rake db:migrate VERSION=20100913132321 By default the environments development, test, cucumber and performance are considered...

You should test the callback methods and its correct invocation in two separate tests. Understand the ActiveRecord note before you...

When submitting textareas, browsers sometimes include carriage returns (\r) instead of just line feeds (\n) at the end of each...

When a spec only runs when it is called directly, but not as part of the whole test suite, make...

makandra dev

This is an awesome gadget in your toolbox, even if your test coverage is great. gem install ruby-debug (Ruby...

Our gem Mail Magnet allows you to override e-mail recipients in ActionMailer so all mails go to a given...

def task_with_hoptoad_notification(options) task(options) do begin yield rescue Exception => e Airbrake.notify(e) raise e

makandra dev

Update RubyGems and Passenger Bundler requires Rubygems >= 1.3.6. Run gem update --system if you have an older version.

Sometimes you want to fetch associations for an ActiveRecord that you already loaded, e.g. when it has deeply nested associations...

github.com

There are three ways to define your own RSpec matchers, with increasing complexibility and options: 1) Use RSpec::Matchers.define

When you roll custom URLs with hacks like routing-filter, you can put a spec like this into spec/routing/routing_spec.rb:

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

regular-expressions.info

You can write regular expressions some different ways, e.g. /regex/ and %r{regex}. For examples, look here. Remember that it...