spec/unit/reader/read_line_spec.rb in tty-prompt-0.10.1 vs spec/unit/reader/read_line_spec.rb in tty-prompt-0.11.0

- old
+ new

@@ -1,33 +1,33 @@ # encoding: utf-8 RSpec.describe TTY::Prompt::Reader, '#read_line' do let(:input) { StringIO.new } let(:output) { StringIO.new } + let(:env) { { "TTY_TEST" => true } } - subject(:reader) { described_class.new(input, output) } + subject(:reader) { described_class.new(input, output, env: env) } it 'masks characters' do - mask = '*' - input << "password" + input << "password\n" input.rewind - answer = reader.read_line(mask) - expect(answer).to eq("password") + answer = reader.read_line(echo: false) + expect(answer).to eq("password\n") end it "echoes characters back" do - input << "password" + input << "password\n" input.rewind answer = reader.read_line - expect(answer).to eq("password") + expect(answer).to eq("password\n") expect(output.string).to eq("") end it 'deletes characters when backspace pressed' do - input << "aa\ba\bcc" + input << "aa\ba\bcc\n" input.rewind answer = reader.read_line - expect(answer).to eq('acc') + expect(answer).to eq("acc\n") end it 'reads multibyte line' do input << "한글" input.rewind