Original BDD example
Here’s the original example that lead to the discussion of the merits of method-centric behavior specs vs. object state-centric behavior specs (or, as Kurt called them, “inside-out” vs “outside-in” specs):
Original method-centric approach with a terrible context name:
blank?
- should be true if all attributes are nil
- should be true if all attributes are blank strings
- should be true if all attributes besides the comparator are blank, regardless of the value of the comparator
- should be false if the assay type is not nil
- should be false if the assay id is not nil
- should be false if the readout definition id is not nil
- should be false if the readout value is not nil
At the very least the context should be changed from blank? to AssayCriterion#blank? or something like that, to make it clear what the heck the context is about. Object state-centric behavior:
An assay criterion whose attributes are all nil
- should be blank
An assay criterion whose attributes are all blank strings # remember these are strings coming from request parameters
- should be blank
An assay criterion with assay type, "cell", but nil everything else
- should not be blank
An assay criterion with assay id, "3", but nil everything else
- should not be blank
An assay criterion with readout definition id, "3", but nil everything else
- should not be blank
An assay criterion with any value of the comparator (say ">"), and nil everything else
- should be blank # that is, the > sign doesn't impact blankness
An assay criterion with readout value, "80", but nil everything else
- should not be blank
I wrote up my original post with this example, but then I looked to find where this method was actually being used, so I could remember the context better, and thought I discovered it was only used in another spec. So I decided to just remove it. Today while coding, however, I discovered it actually is used by real code, so my bad.