File: apply_to_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 (24 lines) | stat: -rw-r--r-- 754 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

RSpec.describe TTY::Prompt::Question::Modifier, "#apply_to" do
  let(:string) { "text   to   be    modified" }

  it "doesn't apply modifiers" do
    modifier = described_class.new([])
    expect(modifier.apply_to(string)).to eq(string)
  end

  it "combines whitespace & letter case modifications" do
    modifiers = %i[collapse capitalize]
    modifier = described_class.new(modifiers)
    modified = modifier.apply_to(string)
    expect(modified).to eq("Text to be modified")
  end

  it "combines letter case & whitespace modifications" do
    modifiers = %i[up collapse]
    modifier = described_class.new(modifiers)
    modified = modifier.apply_to(string)
    expect(modified).to eq("TEXT TO BE MODIFIED")
  end
end