Sha256: 65a285df3b41c42eab316d9e6145db87dd06a0bc7cc5a525dcacac6a7e9cbe70

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

# encoding: utf-8

RSpec.describe TTY::Prompt, '#say' do

  subject(:prompt) { TTY::TestPrompt.new }

  it 'prints an empty message' do
    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 eq("Hell yeah!\n")
    end

    it 'prints a message with implicit newline' do
      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 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 eq("Hell\n yeah! ")
    end

    it 'prints a message without newline' do
      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 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 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 eq("\e[32mHell yeah! \e[0m")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tty-prompt-0.9.0 spec/unit/say_spec.rb
tty-prompt-0.8.0 spec/unit/say_spec.rb
tty-prompt-0.7.1 spec/unit/say_spec.rb
tty-prompt-0.7.0 spec/unit/say_spec.rb
tty-prompt-0.6.0 spec/unit/say_spec.rb
tty-prompt-0.5.0 spec/unit/say_spec.rb
tty-prompt-0.4.0 spec/unit/say_spec.rb
tty-prompt-0.3.0 spec/unit/say_spec.rb