Sha256: c9b80f23b908af05414a0f92373297be0e2370d9434a5cd2f883efbea2ee44ab

Contents?: true

Size: 463 Bytes

Versions: 3

Compression:

Stored size: 463 Bytes

Contents

# encoding: utf-8

RSpec.describe TTY::Prompt::Question, 'convert file' do
  it "converts to file" do
    ::File.write('test.txt', 'foobar')

    prompt = TTY::TestPrompt.new
    prompt.input << "test.txt"
    prompt.input.rewind

    answer = prompt.ask("Which file to open?", convert: :file)

    expect(::File.basename(answer)).to eq('test.txt')
    expect(::File.read(answer)).to eq('foobar')

    ::File.unlink('test.txt') unless Gem.win_platform?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-prompt-0.17.2 spec/unit/converters/convert_file_spec.rb
tty-prompt-0.17.1 spec/unit/converters/convert_file_spec.rb
tty-prompt-0.17.0 spec/unit/converters/convert_file_spec.rb