Sha256: 6b1d70e3ba9a3d645c4d13e1ea29dd85bcba87058f75e6674ac0056dd0bf8b49

Contents?: true

Size: 714 Bytes

Versions: 10

Compression:

Stored size: 714 Bytes

Contents

# encoding: utf-8

RSpec.describe TTY::Prompt::Question::Modifier, '#whitespace' do
  let(:string) { "  text\t \n  to\t   modify\r\n" }

  it "trims whitespace" do
    modified = described_class.whitespace(:trim, string)
    expect(modified).to eq("text\t \n  to\t   modify")
  end

  it "chomps whitespace" do
    modified = described_class.whitespace(:chomp, string)
    expect(modified).to eq("  text\t \n  to\t   modify")
  end

  it "collapses text" do
    modified = described_class.whitespace(:collapse, string)
    expect(modified).to eq(" text to modify ")
  end

  it "removes whitespace" do
    modified = described_class.whitespace(:remove, string)
    expect(modified).to eq("texttomodify")
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tty-prompt-0.10.1 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.10.0 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.9.0 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.8.0 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.7.1 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.7.0 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.6.0 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.5.0 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.4.0 spec/unit/question/modifier/whitespace_spec.rb
tty-prompt-0.3.0 spec/unit/question/modifier/whitespace_spec.rb