File: memory_spec.rb

package info (click to toggle)
ruby-benchmark-memory 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: ruby: 1,121; makefile: 7; sh: 4
file content (34 lines) | stat: -rw-r--r-- 790 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Benchmark::Memory do
  it 'has a version number' do
    expect(Benchmark::Memory::VERSION).not_to be nil
  end

  it 'exposes .memory on Benchmark' do
    expect(Benchmark).to respond_to(:memory)
  end

  describe '.memory' do
    around(:each) do |spec|
      old_stdout = $stdout
      $stdout = StringIO.new
      spec.run
      $stdout = old_stdout
    end

    it 'raises an error when not given a block' do
      expect { Benchmark.memory }.to raise_error(
        Benchmark::Memory::ConfigurationError
      )
    end

    it 'returns a report' do
      # rubocop:disable Lint/EmptyBlock
      expect(Benchmark.memory {}).to be_a(Benchmark::Memory::Report)
      # rubocop:enable Lint/EmptyBlock
    end
  end
end