Skip to content

Instantly share code, notes, and snippets.

@elcontrastador
Created September 12, 2010 06:09
Show Gist options
  • Save elcontrastador/575891 to your computer and use it in GitHub Desktop.
Save elcontrastador/575891 to your computer and use it in GitHub Desktop.
# Using Rails 3.0.0, mri 1.9.2p0, shoulda 2.11.3
# Problem: shoulda validate_format of passes with any value in .with()
class CablingUnderTestTest < ActiveSupport::TestCase
should belong_to(:test_result)
should validate_format_of(:pass_fail).with(/^(PASS|FAIL)$/).
with_message(/^Must be 'PASS' or 'FAIL'$/)
class CablingUnderTest < ActiveRecord::Base
belongs_to :test_result
# validates_format_of :pass_fail, :with => /^(PASS|FAIL)$/,
# :message => "Must be 'PASS' or 'FAIL'"
redii-mbpro:ctr tyler$ rake test:units
(in /Users/tyler/0-repos/planB/ctr)
Loaded suite /Users/tyler/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.............
Finished in 0.220958 seconds.
13 tests, 20 assertions, 0 failures, 0 errors, 0 skips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment