GithubHelp home page GithubHelp logo

The input stream is exhausted about highline HOT 2 CLOSED

jeg2 avatar jeg2 commented on June 24, 2024
The input stream is exhausted

from highline.

Comments (2)

JEG2 avatar JEG2 commented on June 24, 2024

This isn't a bug in HighLine and it isn't related to Readline (which isn't used in this example).

The issue is that you are passing an empty StringIO for HighLine to read content from. That returns nil, just as an exhausted IO object would:

>> StringIO.new.gets
=> nil

We just need to provide some answer for HighLine to read. I realize you aren't using it in the test, but HighLine reads for input before we ever get to your assertion.

Here's how I got your test to run:

require 'test/unit'
require 'stringio'
require 'highline'

def ask_question(input = $stdin, output = $stdout)
  highline = HighLine.new(input, output)
  highline.ask("How are you?")
end

class HighlineTest < Test::Unit::TestCase
  def setup
    @input = StringIO.new("some answer")
    @output = StringIO.new
    ask_question(@input, @output)
  end

  def test_ask_question_returns_prompt
    assert_equal "How are you?\n", @output.string
  end
end

Hope that helps

from highline.

dyba avatar dyba commented on June 24, 2024

@JEG2 Thanks for your speedy response! It's clear to me now.

from highline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.