Module: RailsMemoryProfiler::MinitestMatchers

Defined in:
lib/rails_memory_profiler/minitest_matchers.rb

Instance Method Summary collapse

Instance Method Details

#assert_allocates_fewer_than(threshold, msg = nil, &block) ⇒ Object



6
7
8
9
10
# File 'lib/rails_memory_profiler/minitest_matchers.rb', line 6

def assert_allocates_fewer_than(threshold, msg = nil, &block)
  count = RailsMemoryProfiler::TestHelper.capture_allocations(&block)
  message = msg || "Expected fewer than #{threshold} allocated objects but got #{count}"
  assert count < threshold, message
end