Sha256: 6be2396e3ef913449b18630f4f337e3bac9c36686fbc84e0d20afd9aa14670b4

Contents?: true

Size: 1.1 KB

Versions: 24

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Infobar::InputOutput do
  io_double = -> {
    Class.new do
      def puts(*) end

      def gets(*) end
    end.new
  }

  around do |example|
    infobar.display.output = io_double.()
    infobar.display.input  = io_double.()
    example.run
    infobar.display.output = $stdout
    infobar.display.input  = $stdin
    infobar.reset
  end

  it 'can puts after clearing' do
    expect(infobar.display).to receive(:clear)
    expect(infobar.display.output).to receive(:puts)
    infobar.puts 'hello'
  end

  it 'can gets after clearing' do
    expect(infobar.display).to receive(:clear)
    expect(infobar.display.input).to receive(:gets)
    infobar.gets
  end

  it 'can output newline' do
    expect(infobar.display).to receive(:newline)
    infobar.newline
  end

  it 'can clear the infobar' do
    expect(infobar.display).to receive(:clear)
    infobar.clear
  end

  it 'does not puts if not showing' do
    begin
      expect(infobar.display.output).not_to receive(:puts)
      infobar.show = false
      infobar.puts 'hello'
    rescue
      infobar.show = true
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
infobar-0.9.0 spec/infobar/input_output_spec.rb
infobar-0.8.1 spec/infobar/input_output_spec.rb
infobar-0.8.0 spec/infobar/input_output_spec.rb
infobar-0.7.4 spec/infobar/input_output_spec.rb
infobar-0.7.2 spec/infobar/input_output_spec.rb
infobar-0.7.1 spec/infobar/input_output_spec.rb
infobar-0.7.0 spec/infobar/input_output_spec.rb
infobar-0.6.2 spec/infobar/input_output_spec.rb
infobar-0.6.1 spec/infobar/input_output_spec.rb
infobar-0.6.0 spec/infobar/input_output_spec.rb
infobar-0.5.1 spec/infobar/input_output_spec.rb
infobar-0.5.0 spec/infobar/input_output_spec.rb
infobar-0.4.0 spec/infobar/input_output_spec.rb
infobar-0.3.0 spec/infobar/input_output_spec.rb
infobar-0.2.0 spec/infobar/input_output_spec.rb
infobar-0.1.1 spec/infobar/input_output_spec.rb
infobar-0.1.0 spec/infobar/input_output_spec.rb
infobar-0.0.7 spec/infobar/input_output_spec.rb
infobar-0.0.6 spec/infobar/input_output_spec.rb
infobar-0.0.5 spec/infobar/input_output_spec.rb