spec/tty/shell/ask_spec.rb in tty-0.0.6 vs spec/tty/shell/ask_spec.rb in tty-0.0.7
- old
+ new
@@ -3,12 +3,14 @@
require 'spec_helper'
describe TTY::Shell, '#ask' do
let(:input) { StringIO.new }
let(:output) { StringIO.new }
+ let(:prefix) { '' }
+ let(:options) { { :prefix => prefix } }
- subject(:shell) { TTY::Shell.new(input, output) }
+ subject(:shell) { TTY::Shell.new(input, output, options) }
it 'prints message' do
shell.ask "What is your name?"
expect(output.string).to eql "What is your name?\n"
end
@@ -21,9 +23,20 @@
it 'prints an empty message and returns nil if EOF is sent to stdin' do
input << nil
input.rewind
q = shell.ask ""
expect(q.read).to eql nil
+ end
+
+ context 'with a prompt prefix' do
+ let(:prefix) { ' > ' }
+
+ it "asks a question with '>'" do
+ input << ''
+ input.rewind
+ q = shell.ask "Are you Polish?"
+ expect(output.string).to eql " > Are you Polish?\n"
+ end
end
it 'asks a question with block' do
input << ''
input.rewind