&nbsp; it &quot;should require a password within the range of 5..40 characters&quot; do<br>&nbsp;&nbsp;&nbsp; person = create(:last_name =&gt; &quot;ruby_tuesday&quot;)<br>&nbsp;&nbsp;&nbsp; person.password.should_not be_nil&nbsp; <br>&nbsp;&nbsp;&nbsp; (5..40) === person.password.length.should
<br>&nbsp; end<br><br>Its true, it really works, tell all your friends!<br><br><div><span class="gmail_quote">On 5/27/07, <b class="gmail_sendername">Sam Aaron</b> &lt;<a href="mailto:sam.maillists@googlemail.com">sam.maillists@googlemail.com
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>On 27 May 2007, at 8.31 pm, Andrew WC Brown wrote:<br>&gt;<br>&gt; I thought this would work:
<br>&gt; person.password.length.should == (5..40)<br>&gt;<br><br>I think that in this case, you want to use the === operator when<br>comparing a number with a range. Instead of trying to see if both of<br>the objects (the number and the range) are the same, the === operator
<br>checks to see if the number is within the range.<br><br>Also, make sure you surround your range with parenthesis (which you<br>are already doing), and put the range on the left hand side of the<br>=== operator for it to work. Have a look at this quick irb session
<br>for an example of what I mean:<br><br> &gt;&gt; (10..50) == 15<br>=&gt; false<br> &gt;&gt; (10..50) === 15<br>=&gt; true<br> &gt;&gt; 10..50 === 15<br>ArgumentError: bad value for range<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from (irb):6<br> &gt;&gt; 15 === 10..50
<br>ArgumentError: bad value for range<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from (irb):7<br> &gt;&gt; 15 === (10..50)<br>=&gt; false<br> &gt;&gt;<br><br>Hope this helps,<br><br>Sam<br><br>---<br><a href="http://sam.aaron.name">http://sam.aaron.name
</a><br><br><br>_______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br>