File: thread_lock_test.rb

package info (click to toggle)
ruby-pry-byebug 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 324 kB
  • sloc: ruby: 1,171; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 546 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
# frozen_string_literal: true

require "test_helper"
require "timeout"

class ThreadLockTest < MiniTest::Spec
  let(:output) { StringIO.new }
  let(:input) { InputTester.new }

  describe "when there's another thread" do
    before do
      input.add 'client.puts("Hello")'
      input.add "IO.select([client], [], [], 1) && client.readline"

      redirect_pry_io(input, output) { load test_file("echo_thread") }
    end

    it "another thread isn't locked" do
      assert_equal "=> \"Hello\\n\"\n", output.string.lines.last
    end
  end
end