Project

stdout

0.0
No commit activity in last 3 years
No release in over 3 years
Change stdout to array object
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Stdout

Change stdout to array object.

What is This?

Change STDOUT output to array object.

Tutorial

require 'stdout'

demo = Stdout::Output.capture { puts "hoge" }

p demo #=> ["hoge\n"]

demo2 = Stdout::Output.capture {
  puts "Hello, "
  puts "World!"
}

p demo2 # => ["Hello, \n", "World!\n"]

So, testing your print method with minitest.

require 'stdout'
require 'minitest/autorun'

class YourClass
  def self.some_method
    puts "aaa"
    puts "bbb"
    puts "ccc"
  end
end

class TestYourClass < MiniTest::Unit::TestCase
  def test_some_method
    expected = [
      "aaa\n",
      "bbb\n",
      "ccc\n"
    ]
    result = Stdout::Output.capture{ YourClass.some_method }
    assert_equal(expected, result)
  end
end

See spec files.

Development

Repository

Environment

After ruby 1.9.

ChangeLog

See doc/ChangeLog file.

Developers

See doc/AUTHORS.

Author

774

Copyright and license

See the file doc/LICENSE.