`stub_licensed_features` does not work sometimes due to memoization
Because Project#licensed_feature_available?
is strong_memoized
, sometimes stub_licensed_features
does not do anything because License.feature_available?(feature)
will no longer be called.
See the following discussion from !9970 (merged) where this happens:
-
@tkuah started a discussion: (+5 comments) Does
stub_licensed_features(file_locks: false)
not work here ?
Workaround
The current workaround is to clear the memoization before each example:
h/t @splattael for this (#10267 (comment 148344480)):
before do
# We use `let_it_be(:project)` so we make sure to clear caches
project.clear_memoization(:licensed_feature_available)
end
Edited by Sean Arnold