Check if two arrays contain the same elements in Ruby, RSpec or Test::Unit

Posted Over 13 years ago by Henning Koch.

RSpec 1, RSpec 2 To test whether two arrays have the same elements regardless of order, RSpec 1 and 2...

Hints for debugging MySQL InnoDB deadlocks

Posted Over 13 years ago by Tobias Kraze.

Deadlocks only occur if two transactions in separate threads compete for the same rows in the database. They usually (but...

How to fix failing controller specs 91% of the time

Posted Over 13 years ago by Arne Hartherz.

If your controller spec never reaches your controller code: Make sure you are signed in. Make sure you are actually...

Virtual attributes for array fields

Posted Over 13 years ago by Henning Koch.

When a has_many association basically serves to store a list of associated strings (tags, categories, ...), it can be convenient...

Hunt down that elusive debug message in Ruby

Posted Over 13 years ago by Henning Koch.

When you just went through a long debug-fest and infested your code with dozens of debug messages, it can...

Take care when joining and selecting on scopes

Posted Over 13 years ago by Arne Hartherz.

Occasionally some complex query must be processed on the database because building thousands of Ruby objects is impracticable.

Test a gem in multiple versions of Rails

Posted Over 13 years ago by Tobias Kraze.

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

Test that a select option is selected with Cucumber

Posted Over 13 years ago by Henning Koch.
macksmind.net

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

Bookmarklet to generate a commit message with Pivotal Tracker story ID and title

Posted Over 13 years ago by Henning Koch.

For clarity and traceability, your commit messages should include the ID and title of the Pivotal Tracker story you're...

Aliases for routes

Posted Over 13 years ago by Tobias Kraze.

The following initializer provides an :alias => "my_route_name" option to restful routes in your route.rb. This simply makes the...

Test that a CSS selector is present with Cucumber

Posted Over 13 years ago by Henning Koch.

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

Bash Cheat Sheet (standard Emacs mode)

Posted Over 13 years ago by Arne Hartherz.
skorks.com

Ctrl + R Search commands you entered previously. Press Ctrl + R again to search further back, Ctrl + Shift + R searches forward...

Standalone Cucumber Test Suite

Posted Over 13 years ago by Lexy.
github.com

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

Request a non-HTML format in controller specs

Posted Over 13 years ago by Henning Koch.

If a controller action responds to other formats than HTML (XML, PDF, Excel, JSON, ...), you can reach that code in...

Migrating to RSpec 2 from RSpec 1

Posted Over 13 years ago by Henning Koch.

You will need to upgrade to RSpec >= 2 and rspec-rails >= 2 for Rails 3. Here are some hints to...

Getting your e-mails back after upgrading Thunderbird to version 3

Posted Over 13 years ago by Arne Hartherz.

If you previously used version 2.x of Thunderbird and upgraded to 3.x (for example through an Ubuntu release...

Force RubyMine to notice file system changes

Posted Over 13 years ago by Arne Hartherz.

If you did file operations inside a shell or for example using Nautilus, it can take quite a while until...

Setting nil values in Machinist blueprints

Posted Over 13 years ago by Arne Hartherz.

Take care when trying to set attributes to nil in a blueprint. Given the following master blueprint: Story.blueprint do

Match strings in a given order with Cucumber and Capybara

Posted Over 13 years ago by Dominik Schöler.

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

Machinist: Refer to another named blueprint inside a blueprint

Posted Over 13 years ago by Arne Hartherz.

Note: We are talking about Machinist 1 here, Machinist 2 may have solved this or might require a different approach...

MySQL: Disable query cache for database profiling

Posted Over 13 years ago by Tobias Kraze.

If you want to see how long your database queries actually take, you need to disable MySQL's query cache...

Even with bundler your gem order can be significant

Posted Over 13 years ago by Henning Koch.

Even when you're using bundler, it might be significant in which order your gems are listed in your Gemfile...

Taking advantage of RSpec's "let" in before blocks

Posted Over 13 years ago by Arne Hartherz.

Inside before :each blocks you can refer to variables that you introduce via let later on. They do not need...

Kill a dead SSH shell

Posted Over 13 years ago by Tobias Kraze.

If a SSH shell dies (from timeout for example), you cannot kill it with the usual CTRL-C or CTRL...