<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><blockquote type="cite"><div><div><div><font class="Apple-style-span" color="#000000"><br></font>On 25 Aug 2008, at 17:53, Nick Hoffman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">At the moment, my plan is to spec out the following possibilities. A property is invalid if its address:</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">1) doesn't begin with a digit;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">2) is shorter than 2 characters;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: 12.0px Helvetica">3) is longer than 128 characters;</font></div> </blockquote></div><div><br></div><div><br></div><div>Personally I think that if those three points are your specification then your RSpec should match that. </div><div><br></div><div>So: </div><div>* it "should not begin with a digit", </div><div>* it "should not be shorter than 2 characters", </div><div>* it "should not be longer than 128 characters" and </div><div>* it "should allow valid addresses" (this is for clarity, so you have an example of a valid address in your documentation). </div><div><br></div><div>If your regex allows or disallows more or less than those four clauses then your specification does not match your implementation. </div><div><br></div></div></blockquote><div><br></div><div>So this is interesting, because my approach seems to be more like this:<div><div><blockquote type="cite"><div><div></div></div></blockquote></div></div></div><div><br></div></div>describe "when the address does not begin with a digit" do</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>it "should be invalid" do ... end</div><div>end</div><div><br></div><div>describe "when the address is less than two characters long" do</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>it "should be invalid" do ... end</div><div>end</div><div><br></div><div>describe "when the address is more than two characters long" do</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>describe "and the address is less than 128 characters long" do</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>it "should be valid" do ... end</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>end<br></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>describe "and the address is more than 128 characters long" do<br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>it "should be invalid" do ... end</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>end<br></div><div><br></div><div>end</div><div><br></div><div><br></div><div>Is anyone else using ExampleGroups like this? Or is it just me?!</div><div><br></div><div>cheers,</div><div>Matt</div></body></html>