I just shipped a small update to SpecsFor that improves the partial-matching story when dealing with dates.
[more]
Prior to this update, if you wanted to see if a DateTime value was “near” the current time, you had to do something like this:
obj.ShouldLookLike(() => new TestObject { DateTimeValue = Some.ValueInRange(DateTime.Now.AddSeconds(-1), DateTime.Now) })
With version 4.3.2 though, you can now use the new Some.DateTimeNear method:
obj.ShouldLookLike(() => new TestObject { DateTimeValue = Some.DateTimeNear(DateTime.Now) })
By default, any value within 1 second of the specified time will match, but you can adjust that globally by changing Some.DefaultDateTimeTolerance to another value.
It’s a small change, but I think it helps the spec convey its intent much more cleanly.
Enjoy!