Undefined Method When Testing Rails Plugins With Shoulda

June 22nd, 2009

This is a quick post to help others who may have this problem in the future, or if I forget how I solved this problem (again).

The problem:

Running rake test in your Ruby on Rails plugin directory results in a method not found error (should_validate_presence_of in my case).

The solution:

  1. Run plugin tests from RAILS_ROOT to properly load environment, include shoulda rails initialization: PLUGIN=url_facade rake test:plugins
  2. Make sure that test_helper.rb includes the following: require ’shoulda’; require ’shoulda/rails’

The solution is pretty easy in the end, but this has tripped me up more than once!

Sticky Advertising

April 14th, 2009

Case Study: Long Tail Experiment Results

April 12th, 2009