File: convert_custom_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 (13 lines) | stat: -rw-r--r-- 434 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
# frozen_string_literal: true

RSpec.describe TTY::Prompt::Question, "convert custom" do
  subject(:prompt) { TTY::Prompt::Test.new }

  it "converts response with custom conversion" do
    prompt.input << "one,two,three\n"
    prompt.input.rewind
    conversion = proc { |input| input.split(/,\s*/) }
    answer = prompt.ask("Ingredients? (comma sep list)", convert: conversion)
    expect(answer).to eq(%w[one two three])
  end
end