You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finally, add this require statement to the top of spec/spec_helper.rb
require'rspec/memory'
Usage
Allocating 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.
RSpec.describe"memory allocations"doinclude_contextRSpec::Memoryit"limits allocation counts"doexpectdo6.times{String.new}end.tolimit_allocations(String=>10)# 10 strings can be allocatedendit"limits allocation counts (hash)"doexpectdo6.times{String.new}end.tolimit_allocations(String=>{count: 10})# 10 strings can be allocatedendit"limits allocation size"doexpectdo6.times{String.new("foo")}end.tolimit_allocations(String=>{size: 1024})# 1 KB of strings can be allocatedendend
Contributing
We welcome contributions to this project.
Fork it.
Create your feature branch (git checkout -b my-new-feature).
Commit your changes (git commit -am 'Add some feature').
Push to the branch (git push origin my-new-feature).