Sha256: ac92b69a3a44acdd47a4220ea3fc890db5ea36f51ab8c6f174876ca7d64abce6

Contents?: true

Size: 920 Bytes

Versions: 15

Compression:

Stored size: 920 Bytes

Contents

# encoding: utf-8

RSpec.describe TTY::Prompt, '#suggest' do
  let(:possible) { %w(status stage stash commit branch blame) }

  subject(:prompt) { TTY::TestPrompt.new }

  it 'suggests few matches' do
    prompt.suggest('sta', possible)
    expect(prompt.output.string).
      to eql("Did you mean one of these?\n        stage\n        stash\n")
  end

  it 'suggests a single match for one character' do
    prompt.suggest('b', possible)
    expect(prompt.output.string).to eql("Did you mean this?\n        blame\n")
  end

  it 'suggests a single match for two characters' do
    prompt.suggest('co', possible)
    expect(prompt.output.string).to eql("Did you mean this?\n        commit\n")
  end

  it 'suggests with different text and indentation' do
    prompt.suggest('b', possible, indent: 4, single_text: 'Perhaps you meant?')
    expect(prompt.output.string).to eql("Perhaps you meant?\n    blame\n")
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
tty-prompt-0.17.2 spec/unit/suggest_spec.rb
tty-prompt-0.17.1 spec/unit/suggest_spec.rb
tty-prompt-0.17.0 spec/unit/suggest_spec.rb
tty-prompt-0.12.0 spec/unit/suggest_spec.rb
tty-prompt-0.11.0 spec/unit/suggest_spec.rb
tty-prompt-0.10.1 spec/unit/suggest_spec.rb
tty-prompt-0.10.0 spec/unit/suggest_spec.rb
tty-prompt-0.9.0 spec/unit/suggest_spec.rb
tty-prompt-0.8.0 spec/unit/suggest_spec.rb
tty-prompt-0.7.1 spec/unit/suggest_spec.rb
tty-prompt-0.7.0 spec/unit/suggest_spec.rb
tty-prompt-0.6.0 spec/unit/suggest_spec.rb
tty-prompt-0.5.0 spec/unit/suggest_spec.rb
tty-prompt-0.4.0 spec/unit/suggest_spec.rb
tty-prompt-0.3.0 spec/unit/suggest_spec.rb