File: script_interface_test.rb

package info (click to toggle)
ruby-byebug 13.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,288 kB
  • sloc: ruby: 9,013; ansic: 1,692; makefile: 4; sh: 4
file content (50 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download
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
50
# frozen_string_literal: true

require "test_helper"

module Byebug
  #
  # Tests the script interface (batch execution of byebug commands from a file)
  #
  class ScriptInterfaceTest < TestCase
    def test_initialize_wires_up_dependencies
      with_new_tempfile("show") do |path|
        interface = ScriptInterface.new(path)

        begin
          assert_instance_of File, interface.input
          assert_instance_of StringIO, interface.output
          assert_equal $stderr, interface.error
        ensure
          interface.close
        end
      end
    end

    def test_initialize_verbose_writes_to_stdout_and_stderr
      with_new_tempfile("show") do |path|
        interface = ScriptInterface.new(path, true)

        begin
          assert_instance_of File, interface.input
          assert_equal $stdout, interface.output
          assert_equal $stderr, interface.error
        ensure
          interface.close
        end
      end
    end

    def test_readline_reads_input_until_first_non_comment
      with_new_tempfile("# Run the show command\nshow\n") do |path|
        interface = ScriptInterface.new(path)

        begin
          assert_equal "show", interface.readline
        ensure
          interface.close
        end
      end
    end
  end
end