File: size_spec.rb

package info (click to toggle)
ruby-tty-screen 0.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: ruby: 483; makefile: 4; sh: 4
file content (24 lines) | stat: -rw-r--r-- 552 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
# frozen_string_literal: true

require "io/console"
require "rspec-benchmark"

RSpec.describe TTY::Screen, ".size" do
  include RSpec::Benchmark::Matchers

  it "detectes size 13x slower than io-console" do
    expect {
      TTY::Screen.size
    }.to perform_slower_than {
      IO.console.winsize
    }.at_most(13).times
  end

  it "performs at least 28K i/s" do
    expect { TTY::Screen.size }.to perform_at_least(28_000).ips
  end

  it "allocates at most 10 objects" do
    expect { TTY::Screen.size }.to perform_allocation(10).objects
  end
end