This updates the Assert::Context#subject to memoize its return
values. I can't remember why we never memoized the subject before
but now that we have memoized lets, it feels awkward/unexpected
to not have memoized subjects.
This also updates the test suite to make use of the memoized
subjects. We had many let's that were only there to be memoized
subject values. They are unnecessary if subjects are implicitly
memoized.
Note: this also updates the instance variable name used to memoize
lets to use the @__assert_{whatever}__ naming convention. This
keeps lets from polluting the instance variable namespace and
conflicting with instance variables created in setup blocks.
Note: I chose to switch-to/use instance_variable_defined? b/c
both subjects and lets can be nil so this isn't a good
memoization signal. A better signal is whether an instance method
is defined or not. This allows nil values to get memoized and
not re-processed.
This updates the
Assert::Context#subject
to memoize its return values. I can't remember why we never memoized the subject before but now that we have memoizedlet
s, it feels awkward/unexpected to not have memoizedsubject
s.This also updates the test suite to make use of the memoized subjects. We had many let's that were only there to be memoized subject values. They are unnecessary if subjects are implicitly memoized.
Note: this also updates the instance variable name used to memoize
let
s to use the@__assert_{whatever}__
naming convention. This keepslet
s from polluting the instance variable namespace and conflicting with instance variables created insetup
blocks.Note: I chose to switch-to/use
instance_variable_defined?
b/c bothsubject
s andlet
s can benil
so this isn't a good memoization signal. A better signal is whether an instance method is defined or not. This allowsnil
values to get memoized and not re-processed.