<div>Two friday's ago I was talking to my pair Cabout a pet peeve I have sometimes. Grouping behaviors by contexts, rather then the inverse. </div><div><br></div><div>So I ask you, in regards to describing behavior in a particular context, have you ever entertained the idea of the describing behavior with a particular context?</div>
<div><br></div><div>For example here is an example of describing behavior inside of a context:</div><div><br></div><div> describe Trip</div><div> context "with no breakfast expenses"</div><div> it "has $0 for breakfast amount"</div>
<div> end</div><div> </div><div> context "with breakfast expenses" do</div><div> it "has a breakfast amount which is the sum total of breakfast expenses"</div><div> end</div><div> end</div>
<div> </div><div>And here's an example of describing the behavior with contexts:</div><div><br></div><div> describe Trip</div><div> behavior "computes breakfast amount" do</div><div> context "with no breakfast expenses" do</div>
<div> it "is $0"</div><div> end</div><div> </div><div> context "with breakfast expenses" do</div><div> it "is the sum of all breakfast expenses" </div><div> end</div>
<div> end</div><div> end</div><div><br></div><div>The difference is subtle, but it inverts how behaviors are described. It also groups contexts for a particular behavior together, rather than grouping the behaviors to a particular context. </div>
<div><br></div><div>It does add another level of verbosity, but it makes my contexts more meaningful because the setup is directly tied to the behavior I'm testing, rather than potentially many behaviors which rely on the same setup.</div>
<div><br></div><div>I'm just thinking out loud at this point, but I'm interested in hearing your thoughts.</div><div><br></div><br>-- <br>Zach Dennis<br><a href="http://www.continuousthinking.com">http://www.continuousthinking.com</a>