Project

ariete

0.0
No commit activity in last 3 years
No release in over 3 years
Ariete is capturing module for STDOUT & STDERR.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

Ariete

Build Status

Ariete is a module that captures $stdout($stderr) and return as String.
It is useful on an unit test.

Requirement

  • Ruby 2.0 or later.

Installation

$ (sudo) gem install 'ariete'

Usage with test-unit

klass.rb

class Klass
  class << self
    def output
      puts "Ariete is a kind of rabbit."
      warn "Ariete means 'Lop' in Italian."
    end
  end
end

klass_spec.rb

require 'test/unit'
require 'ariete'
require_relative 'klass'

class TestKlass < Test::Unit::TestCase
  include Ariete

  def test_output_std
    captured_string = capture_stdout { Klass.output }
    assert_equal "Ariete is a kind of rabbit.\n", captured_string
  end

  def test_output_err
    captured_string = capture_stderr { Klass.output }
    assert_equal "Ariete means 'Lop' in Italian.\n", captured_string
  end
end

with RSpec

Do you want some matchers for RSpec?
You can use ariete-rspec gem to extend RSpec.

Contributing

  1. Fork it ( https://github.com/mozamimy/ariete/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request