File: quit_test.rb

package info (click to toggle)
ruby-byebug 11.1.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,252 kB
  • sloc: ruby: 8,835; ansic: 1,662; sh: 6; makefile: 4
file content (49 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

require "test_helper"
require "minitest/mock"

module Byebug
  #
  # Tests exiting Byebug functionality.
  #
  class QuitTest < TestCase
    def faking_exit!
      Process.stub(:exit!, nil) { yield }
    end

    def test_quit_finishes_byebug_if_user_confirms
      faking_exit! do
        enter "quit", "y"
        debug_code(minimal_program)

        check_output_includes "Really quit? (y/n)"
      end
    end

    def test_quit_quits_inmediately_if_used_with_bang
      faking_exit! do
        enter "quit!"
        debug_code(minimal_program)

        check_output_doesnt_include "Really quit? (y/n)"
      end
    end

    def test_quit_quits_inmediately_if_used_with_unconditionally
      faking_exit! do
        enter "quit unconditionally"
        debug_code(minimal_program)

        check_output_doesnt_include "Really quit? (y/n)"
      end
    end

    def test_does_not_quit_if_user_did_not_confirm
      enter "quit", "n"
      debug_code(minimal_program)

      check_output_includes "Really quit? (y/n)"
    end
  end
end