File: utils_spec.rb

package info (click to toggle)
ruby-tty-prompt 0.23.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,452 kB
  • sloc: ruby: 8,847; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 671 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
# frozen_string_literal: true

RSpec.describe TTY::Utils do
  context "#blank?" do
    {
      nil => true,
      "" => true,
      "\n\t\s" => true,
      "    " => true,
      "foo" => false,
      :foo => false
    }.each do |value, result|
      it "detects blank of #{value.inspect} as #{result}" do
        expect(described_class.blank?(value)).to eq(result)
      end
    end
  end

  context "#deep_copy" do
    [
      "",
      ["foo", {bar: "baz"}, :fum, 11]
    ].each do |obj|
      it "copies #{obj.inspect}" do
        copy = described_class.deep_copy(obj)
        expect(obj).to eq(copy)
        expect(obj).not_to equal(copy)
      end
    end
  end
end