File: report_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 (35 lines) | stat: -rw-r--r-- 831 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
35
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Benchmark::Memory::Report do
  it 'is initialized with a blank list of entries' do
    report = described_class.new

    expect(report.entries).to be_empty
  end

  describe '#add_entry' do
    it 'adds an entry to the list of entries' do
      report = described_class.new
      task = Benchmark::Memory::Job::Task.new('do nothing', -> {})
      measurement = create_measurement

      expect { report.add_entry(task, measurement) }.to(
        change(report.entries, :count).by(1)
      )
    end
  end

  def create_measurement
    Benchmark::Memory::Measurement.new(
      memory: create_metric,
      objects: create_metric,
      strings: create_metric
    )
  end

  def create_metric
    Benchmark::Memory::Measurement::Metric.new(:fake, 0, 0)
  end
end