From 26f49061cf0c85daf78ee3a5678cb02021e39fc8 Mon Sep 17 00:00:00 2001 From: zyc9012 Date: Wed, 4 Sep 2024 09:44:49 +0800 Subject: [PATCH] Add multi thread test --- spec/multi_thread_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spec/multi_thread_spec.rb diff --git a/spec/multi_thread_spec.rb b/spec/multi_thread_spec.rb new file mode 100644 index 0000000..5cc8d1f --- /dev/null +++ b/spec/multi_thread_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe "Multi threading" do + it 'should be thread-safe' do + 10000.times.map do + Thread.new do + random_str = (0...32).map { (65 + rand(58)).chr }.join + doc = Nokolexbor::HTML('
' + random_str + '
') + _(doc.css("div ::text").text).must_equal random_str + end + end.each(&:join) + end +end \ No newline at end of file