{"id":19316011,"url":"https://github.com/socketry/rspec-memory","last_synced_at":"2025-03-16T00:09:43.167Z","repository":{"id":35009486,"uuid":"196134153","full_name":"socketry/rspec-memory","owner":"socketry","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-03T22:25:06.000Z","size":40,"stargazers_count":16,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-28T22:17:32.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/socketry.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-10T04:58:08.000Z","updated_at":"2024-06-29T19:20:42.000Z","dependencies_parsed_at":"2024-06-19T04:11:21.524Z","dependency_job_id":"cef753d9-7559-4006-a185-edfd2474319a","html_url":"https://github.com/socketry/rspec-memory","commit_stats":{"total_commits":17,"total_committers":5,"mean_commits":3.4,"dds":0.3529411764705882,"last_synced_commit":"1e063ea45b02784fba760444552d0d1096721e21"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Frspec-memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Frspec-memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Frspec-memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Frspec-memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socketry","download_url":"https://codeload.github.com/socketry/rspec-memory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806070,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:09:25.589Z","updated_at":"2025-03-16T00:09:43.139Z","avatar_url":"https://github.com/socketry.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RSpec::Memory\n\nMake assertions about memory usage.\n\n[![Development Status](https://github.com/socketry/rspec-memory/workflows/Test/badge.svg)](https://github.com/socketry/rspec-memory/actions?workflow=Test)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n``` ruby\ngem 'rspec-memory'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rspec-memory\n\nFinally, add this require statement to the top of `spec/spec_helper.rb`\n\n``` ruby\nrequire 'rspec/memory'\n```\n\n## Usage\n\nAllocating large amounts of objects can lead to memory problems. `RSpec::Memory` adds a `limit_allocations` matcher, which tracks the number of allocations and memory size for each object type and allows you to specify expected limits.\n\n``` ruby\nRSpec.describe \"memory allocations\" do\n\tinclude_context RSpec::Memory\n\t\n\tit \"limits allocation counts\" do\n\t\texpect do\n\t\t\t6.times{String.new}\n\t\tend.to limit_allocations(String =\u003e 10) # 10 strings can be allocated\n\tend\n\t\n\tit \"limits allocation counts (hash)\" do\n\t\texpect do\n\t\t\t6.times{String.new}\n\t\tend.to limit_allocations(String =\u003e {count: 10}) # 10 strings can be allocated\n\tend\n\t\n\tit \"limits allocation size\" do\n\t\texpect do\n\t\t\t6.times{String.new(\"foo\")}\n\t\tend.to limit_allocations(String =\u003e {size: 1024}) # 1 KB of strings can be allocated\n\tend\nend\n```\n\n## Contributing\n\nWe welcome contributions to this project.\n\n1.  Fork it.\n2.  Create your feature branch (`git checkout -b my-new-feature`).\n3.  Commit your changes (`git commit -am 'Add some feature'`).\n4.  Push to the branch (`git push origin my-new-feature`).\n5.  Create new Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketry%2Frspec-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocketry%2Frspec-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketry%2Frspec-memory/lists"}