Recent Blog Posts

  • JarAnalyzer in Google Code
    By Kirk Knoernschild - Thursday Nov, 20
    JarAnalyzer now has it’s own Google Code location. You can browse the source code online, check the source code out, and do all of the other exciting things that you can do with a subversion rep... more »
  • How Long-Term is Your Strategy?
    By Johanna Rothman - Thursday Nov, 20
    I was thinking about the automakers, and how they want many billions of $ from Washington (please, noooo). I don’t know what their strategic planning is, but it seems not to have changed from th... more »
  • I’m on Twitter
    By Kirk Knoernschild - Wednesday Nov, 19
    I’ve jumped on the Twitter bandwagon. Possibly a little slow, but better late than never. I’ve started following a few people, and so far I find it fun and interesting. I intend to post mo... more »
  • Fast Sphinx indexing with foxy fixtures
    By Matthew Bass - Wednesday Nov, 19
    Can Sphinx and foxy fixtures place nicely together? Due to the way Sphinx indexing works, foxy fixtures will often slow down the indexing process drastically. This article explains how to overcome thi... more »
  • Printing an array in multiple table columns
    By Matthew Bass - Wednesday Nov, 19
    <% @categories.in_groups_of(2).each do |group| %>   <tr>   <% group.each do |category| %>     <td><%=h category.name %></td>... more »

rspec_validation_expectations gem released

Posted by: Matthew Bass on 08/22/2008

I just released a new gem on GitHub that provides some common validation expectations to rspec. Instead of writing specs to verify that your models are handling validation correctly, these expectations simply check that the validation is getting declared correctly in your model. For example:

describe User do
  it_should_validate_presence_of :first_name, :last_name, :email
  it_should_validate_numericality_of :zip
  it_should_validate_uniqueness_of :email
end

Since the expectations never hit the database, they are also faster than testing the traditional way. It’s dead simple to install on Rails 2.1 or later:

script/plugin install git://github.com/pelargir/rspec_validation_expectations.git

The expectations become available to your specs immediately.


be the first to rate this blog


About Matthew Bass

Matthew Bass is an independent software developer, entrepreneur, speaker, and writer. He has over ten years of experience across a diverse set of technologies and has worked at places like SAS Institute, the world's largest privately held software company. An agilist from the very beginning, he continues evangelizing and experimenting with pair programming, test-first and behavior-driven development, and continuous integration. Matthew has spoken at several regional and national software conferences and regularly writes for publications like InfoQ.