spec/unit/say_spec.rb in tty-prompt-0.2.0 vs spec/unit/say_spec.rb in tty-prompt-0.3.0

- old
+ new

@@ -1,62 +1,57 @@ # encoding: utf-8 -require 'spec_helper' - RSpec.describe TTY::Prompt, '#say' do - let(:color) { Pastel.new(enabled: true) } subject(:prompt) { TTY::TestPrompt.new } - before { allow(Pastel).to receive(:new).and_return(color) } - it 'prints an empty message' do - prompt.say "" - expect(prompt.output.string).to eql "" + prompt.say('') + expect(prompt.output.string).to eq('') end context 'with new line' do it 'prints a message with newline' do - prompt.say "Hell yeah!\n" - expect(prompt.output.string).to eql "Hell yeah!\n" + prompt.say("Hell yeah!\n") + expect(prompt.output.string).to eq("Hell yeah!\n") end it 'prints a message with implicit newline' do - prompt.say "Hell yeah!\n" - expect(prompt.output.string).to eql "Hell yeah!\n" + prompt.say("Hell yeah!\n") + expect(prompt.output.string).to eq("Hell yeah!\n") end it 'prints a message with newline within text' do - prompt.say "Hell\n yeah!" - expect(prompt.output.string).to eql "Hell\n yeah!\n" + prompt.say("Hell\n yeah!") + expect(prompt.output.string).to eq("Hell\n yeah!\n") end it 'prints a message with newline within text and blank space' do - prompt.say "Hell\n yeah! " - expect(prompt.output.string).to eql "Hell\n yeah! " + prompt.say("Hell\n yeah! ") + expect(prompt.output.string).to eq("Hell\n yeah! ") end it 'prints a message without newline' do - prompt.say "Hell yeah!", newline: false - expect(prompt.output.string).to eql "Hell yeah!" + prompt.say("Hell yeah!", newline: false) + expect(prompt.output.string).to eq("Hell yeah!") end end context 'with tab or space' do it 'prints ' do - prompt.say "Hell yeah!\t" - expect(prompt.output.string).to eql "Hell yeah!\t" + prompt.say("Hell yeah!\t") + expect(prompt.output.string).to eq("Hell yeah!\t") end end context 'with color' do it 'prints message with ansi color' do - prompt.say "Hell yeah!", color: :green - expect(prompt.output.string).to eql "\e[32mHell yeah!\e[0m\n" + prompt.say('Hell yeah!', color: :green) + expect(prompt.output.string).to eq("\e[32mHell yeah!\e[0m\n") end it 'prints message with ansi color without newline' do - prompt.say "Hell yeah! ", color: :green - expect(prompt.output.string).to eql "\e[32mHell yeah! \e[0m" + prompt.say('Hell yeah! ', color: :green) + expect(prompt.output.string).to eq("\e[32mHell yeah! \e[0m") end end end