dememoize is a Ruby gem designed to remove memoized instance variables from classes or objects. It is primarily used in testing (specifically with RSpec) to ensure that memoized values are recalculated under different test conditions.
DememoizeModule (lib/dememoize.rb): Contains the core logic for removing instance variables.dememoize(obj, *instance_variables): Removes specified instance variables (or all if none specified) from the given object.remove_instance_variable_if_defined(obj, name): Safely removes a specific instance variable if it exists.
- RSpec Helpers (
lib/dememoize/rspec_dememoize.rb): Provides shared contexts for RSpec tests.include_context "with dememoized variable", :@name, object: my_objinclude_context "with dememoized class variable", :@name, clazz: MyClass(defaults todescribed_class)
- Ruby 3.3+ (Targeted in RuboCop and CI)
- Bundler
bundle installUse the specs.sh script to run the full RSpec suite:
./specs.shThe project enforces strict quality standards using RuboCop, Fasterer, and Reek. Use quality.sh to run all checks:
./quality.shGitHub Actions (.github/workflows/specs.yml) runs tests and quality checks against Ruby versions 3.3, 3.4, and 4.0.
lib/: Source code.spec/: RSpec tests.quality.sh: Runs RuboCop, Fasterer, and Reek.specs.sh: Runs RSpec.dememoize.gemspec: Gem configuration.CHANGELOG.md: Project history (needs manual updates during releases).
- RuboCop: Follow the project's RuboCop configuration (
.rubocop.yml). - RSpec: All new features must include comprehensive RSpec tests in the
spec/directory. - Versioning: Follow Semantic Versioning. Version is defined in
lib/dememoize/version.rb. - Gemspec: Never put a ruby requirement in the gemspec, leave that up to the end user to check.