File: test_basic_root.rb

package info (click to toggle)
ruby-cri 2.15.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 384 kB
  • sloc: ruby: 2,776; makefile: 11
file content (30 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

require 'helper'

module Cri
  class BasicRootTestCase < Cri::TestCase
    def test_run_with_help
      cmd = Cri::Command.new_basic_root

      stdout, _stderr = capture_io_while do
        err = assert_raises SystemExit do
          cmd.run(%w[-h])
        end
        assert_equal 0, err.status
      end

      assert stdout =~ /COMMANDS.*\n.*help.*show help/
    end

    def test_run_with_help_no_exit
      cmd = Cri::Command.new_basic_root

      stdout, _stderr = capture_io_while do
        cmd.run(%w[-h], {}, hard_exit: false)
      end

      assert stdout =~ /COMMANDS.*\n.*help.*show help/
    end
  end
end