RSpec 1 (Rails 2) With the most recent spec_candy.rb helpers you can say: User.stub_any_instance(:foo => :bar) user = User.new...

To show the collation of your tables you have to login to the MySQL console and execute SHOW TABLE STATUS...

linux.die.net

You can convert git commits into patch files. Those can be used to apply to a different repository [1] or...

stackoverflow.com

The solution in this card is based on a stack overflow post by Leventix. If you need to make request...

The most common use case for Ruby's #collect is to call a method on each list element and collect...

Calling #gsub on a string that was previously marked as #html_safe will lead to unexpected behavior. E. g. backreferences...

web.archive.org

Single step and slow motion for Cucumber scenarios can come in handy, especially in @javascript scenarios. # features/support/examiners.rb AfterStep('@slow_motion...

In order to open a MySQL shell without the need to enter user and password, you can say the following...

The technique described in this card has an important caveat: The result of GROUP_CONCAT is truncated to the maximum...

Sometimes you want to use a vanilla Ruby method like a block. You can use Object#method to obtain a...

Consider you have a website vhost listening to www.example.com, redirecting all incoming requests that do not talk about the configured...

Observed on Rails 2.3 and machinist 1.0.6 Like the title says, when you define the method empty? like in the...

When you don't know which options are available, but need to have an option selected, use this step.

Remember how Rails 2 came with an awesome feature that broke all code using Time.now or Time.parse? This behavior is...

Simple: Tell the application controller how to handle exceptions, here a RecordNotFound error. Do this with the following line: # application_controller.rb...

When writing a piece of reusable code, you sometimes need to have separate code for Rails 2 and Rails 3...

While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals...

I recently browsed through the ActiveSupport code and found some nice stuff I did not know about: ActiveSupport::Callbacks

When the Ruby parser module of Ruby-GetText comes across a file in one of its search directories (e.g. lib/scripts...

Open up your "Base File.sublime-settings" (Preferences Menu → File Settings – User) in Sublime Text 2. Add entries for font_face...

Hint: There's another card with this helper for Cucumber features. Sometimes you feel like you need to stub some...

makandra dev

When you need to create a locale for a language variant (like Austrian for German), you probably don't want...

Passenger gives you the possibility to define in which environment your app should be started. This has to be added...

When you have a program running in a hidden X screen (like with Xvfb for Selenium tests) you may want...