<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/rails_root/db/migrate/009_add_ssn_to_users.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -271,6 +271,50 @@ module ThoughtBot # :nodoc:
           assert object.save, &quot;Could not save #{klass} with #{attribute} set to \&quot;#{valid_value}\&quot;&quot;
         end
       end
+      
+      # Ensures that the length of the attribute is exactly a certain length
+      # Requires an existing record
+      #
+      # Options:
+      # * &lt;tt&gt;:message&lt;/tt&gt; - value the test expects to find in &lt;tt&gt;errors.on(:attribute)&lt;/tt&gt;.  
+      #   Regexp or string.  Default = &lt;tt&gt;/short/&lt;/tt&gt;
+      #
+      # Example:
+      #   should_ensure_length_is :ssn, 9
+      #
+      def should_ensure_length_is(attribute, length, opts = {})
+         message = get_options!([opts], :message)
+         message ||= /wrong length/
+
+         klass = model_class
+
+         should &quot;not allow #{attribute} to be less than #{length} chars long&quot; do
+           min_value = &quot;x&quot; * (length - 1)
+           assert object = klass.find(:first), &quot;Can't find first #{klass}&quot;
+           object.send(&quot;#{attribute}=&quot;, min_value)
+           assert !object.save, &quot;Saved #{klass} with #{attribute} set to \&quot;#{min_value}\&quot;&quot;
+           assert object.errors.on(attribute), &quot;There are no errors set on #{attribute} after being set to \&quot;#{min_value}\&quot;&quot;
+           assert_contains(object.errors.on(attribute), message, &quot;when set to \&quot;#{min_value}\&quot;&quot;)
+         end
+         
+         should &quot;not allow #{attribute} to be greater than #{length} chars long&quot; do
+           max_value = &quot;x&quot; * (length + 1)
+           assert object = klass.find(:first), &quot;Can't find first #{klass}&quot;
+           object.send(&quot;#{attribute}=&quot;, max_value)
+           assert !object.save, &quot;Saved #{klass} with #{attribute} set to \&quot;#{max_value}\&quot;&quot;
+           assert object.errors.on(attribute), &quot;There are no errors set on #{attribute} after being set to \&quot;#{max_value}\&quot;&quot;
+           assert_contains(object.errors.on(attribute), message, &quot;when set to \&quot;#{max_value}\&quot;&quot;)
+         end
+         
+          should &quot;allow #{attribute} to be #{length} chars long&quot; do
+             valid_value = &quot;x&quot; * (length)
+             assert object = klass.find(:first), &quot;Can't find first #{klass}&quot;
+             object.send(&quot;#{attribute}=&quot;, valid_value)
+             object.save
+             assert_does_not_contain(object.errors.on(attribute), message, &quot;when set to \&quot;#{valid_value}\&quot;&quot;)
+           end
+         
+       end
 
       # Ensure that the attribute is in the range specified
       # Requires an existing record</diff>
      <filename>lib/shoulda/active_record_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,3 +3,4 @@ first:
   name: Some dude
   age: 2
   email: none@none.com
+  ssn: 123456789</diff>
      <filename>test/fixtures/users.yml</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ class UsersControllerTest &lt; Test::Unit::TestCase
     resource.actions    = [:index, :show, :new, :edit, :update, :create, :destroy]
     resource.formats    = [:html, :xml]
     
-    resource.create.params = { :name =&gt; &quot;bob&quot;, :email =&gt; 'bob@bob.com', :age =&gt; 13}
+    resource.create.params = { :name =&gt; &quot;bob&quot;, :email =&gt; 'bob@bob.com', :age =&gt; 13, :ssn =&gt; &quot;123456789&quot;}
     resource.update.params = { :name =&gt; &quot;sue&quot; }
     
     resource.create.redirect  = &quot;user_url(@user)&quot;</diff>
      <filename>test/functional/users_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,4 +11,6 @@ class User &lt; ActiveRecord::Base
   validates_inclusion_of :age, :in =&gt; 1..100
   validates_acceptance_of :eula
   validates_uniqueness_of :email, :scope =&gt; :name
+  validates_length_of :ssn, :is =&gt; 9, :message =&gt; &quot;Social Security Number is not the right length&quot;
+  validates_numericality_of :ssn
 end</diff>
      <filename>test/rails_root/app/models/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,4 +24,7 @@ class UserTest &lt; Test::Unit::TestCase
                                 :null =&gt; true,     :primary =&gt; false, :scale     =&gt; nil, :sql_type =&gt; 'varchar(255)'
   should_require_acceptance_of :eula
   should_require_unique_attributes :email, :scoped_to =&gt; :name
+  
+  should_ensure_length_is :ssn, 9, :message =&gt; &quot;Social Security Number is not the right length&quot;
+  should_only_allow_numeric_values_for :ssn
 end</diff>
      <filename>test/unit/user_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5e4222694b8373c2a6f56afd9cef99c9cb223aa9</id>
    </parent>
  </parents>
  <author>
    <name>Chris O'Sullivan</name>
    <email>thechrisoshow@gmail.com</email>
  </author>
  <url>http://github.com/thechrisoshow/shoulda/commit/6511bcf398b47c6dff17d87f963dda01ff27051b</url>
  <id>6511bcf398b47c6dff17d87f963dda01ff27051b</id>
  <committed-date>2008-06-19T09:23:45-07:00</committed-date>
  <authored-date>2008-06-19T09:23:45-07:00</authored-date>
  <message>Added should_ensure_length_is (including tests) [#32]</message>
  <tree>182ca19cde5f3d86754061cfde7e1d5b214b421d</tree>
  <committer>
    <name>Chris O'Sullivan</name>
    <email>thechrisoshow@gmail.com</email>
  </committer>
</commit>
