<div>Two friday&#39;s ago I was talking to my pair Cabout a pet peeve I have sometimes. Grouping behaviors by contexts, rather then the inverse.&nbsp;</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>&nbsp;&nbsp;describe Trip</div><div>&nbsp;&nbsp; &nbsp;context &quot;with no breakfast expenses&quot;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;it &quot;has $0 for breakfast amount&quot;</div>
<div>&nbsp;&nbsp; &nbsp;end</div><div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;context &quot;with breakfast expenses&quot; do</div><div>&nbsp;&nbsp; &nbsp; &nbsp;it &quot;has a breakfast amount which is the sum total of breakfast expenses&quot;</div><div>&nbsp;&nbsp; &nbsp;end</div><div>&nbsp;&nbsp;end</div>
<div>&nbsp;&nbsp;</div><div>And here&#39;s an example of describing the behavior with contexts:</div><div><br></div><div>&nbsp;&nbsp;describe Trip</div><div>&nbsp;&nbsp; &nbsp;behavior &quot;computes breakfast amount&quot; do</div><div>&nbsp;&nbsp; &nbsp; &nbsp;context &quot;with no breakfast expenses&quot; do</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;it &quot;is $0&quot;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;end</div><div>&nbsp;&nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;context &quot;with breakfast expenses&quot; do</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;it &quot;is the sum of all breakfast expenses&quot;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;end</div>
<div>&nbsp;&nbsp; &nbsp;end</div><div>&nbsp;&nbsp;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.&nbsp;</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&#39;m testing, rather than potentially many behaviors which rely on the same setup.</div>
<div><br></div><div>I&#39;m just thinking out loud at this point, but I&#39;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>