Generate ActiveRecord model mocks for fast unit tests that don't require Rails or a database.
ActiveMocker is a Ruby gem that generates mock classes from ActiveRecord models to speed up unit testing. It creates standalone stubs that replicate ActiveRecord's API, allowing tests to run without loading Rails or connecting to a database, which can result in up to 10x performance improvements. The tool automatically regenerates mocks when the schema changes to keep them in sync with the actual models.
Ruby on Rails developers who write unit tests for ActiveRecord models and want to improve test execution speed by eliminating dependencies on Rails and the database.
Developers choose ActiveMocker because it provides a reliable way to mock ActiveRecord models with high compatibility, automatic synchronization with schema changes, and seamless integration with RSpec, leading to faster and more isolated unit tests.
Generate mocks from ActiveRecord models for unit tests that run fast because they don’t need to load Rails or a database.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
By eliminating Rails and database loads, unit tests can run up to 10x faster, as highlighted in the project description, making it ideal for large test suites.
Mocks automatically regenerate when the database schema changes via rake tasks, preventing stale mocks and ensuring test reliability with production code.
Includes support for many ActiveRecord methods like query interfaces, associations, and instance methods, allowing mocks to behave similarly to real models in tests.
Integrates easily with RSpec via metadata tags for automatic constant stubbing, reducing setup boilerplate and enabling cleaner test code.
Does not support validations, callbacks, or SQL queries, which are essential for many Rails tests, limiting its use to basic model mocking.
While schema changes trigger regeneration, model changes need manual execution of a rake task or file watchers, adding maintenance overhead.
As noted in known limitations, associations may not always be correctly mirrored in mocks, especially for non-standard or custom setups, leading to potential test gaps.