Sha256: 1aadb9383bc5ab9cee4c3f363ad0f9f6a1eba6ee31e96896aef51a295b232a2b

Contents?: true

Size: 827 Bytes

Versions: 5

Compression:

Stored size: 827 Bytes

Contents

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
require 'test_helper'
require 'stringio'

context "Rip::UI" do
  setup do
    @output = ''
    @ui = Rip::UI.new(StringIO.new(@output))
  end

  test 'puts message' do
    @ui.puts 'hello'
    assert_equal 'hello', @output.chomp
  end

  test 'empty puts' do
    @ui.puts
    assert_equal "\n", @output
  end

  test 'prepends "rip: " to abort message' do
    begin
      old = Kernel.method(:abort)
      class << Kernel; def abort(msg); msg end end
      assert_equal "rip: goodbye", @ui.abort("goodbye")
    ensure
      class << Kernel; self end.class_eval { define_method(:abort, old) }
    end
  end

  test "does not perform actions when no IO given" do
    ui = Rip::UI.new
    ui.puts 'this should not show up'
    ui.abort 'this should not abort'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rip-0.0.4 test/ui_test.rb
rip-0.0.5 test/ui_test.rb
rip-0.0.3 test/ui_test.rb
rip-0.0.2 test/ui_test.rb
rip-0.0.1 test/ui_test.rb