أعمل على دعم Ruby 3 وواجهت فشلاً في الاختبار.
خطوات التكرار
- تشغيل Ruby 3.0.2
$ cd discourse
$ bundle exec rspec spec/models/optimized_image_spec.rb:10
النتيجة المتوقعة
ينبغي أن ينتهي بنجاح كما يلي
1 example, 0 failures
النتيجة الفعلية
يحدث الفشل دائمًا كما يلي.
$ bundle exec rspec spec/models/optimized_image_spec.rb:10
Run options: include {:locations=>{"./spec/models/optimized_image_spec.rb"=>[10]}}
Randomized with seed 44957
F
Failures:
1) OptimizedImage.crop should produce cropped images (requires ImageMagick 7)
Failure/Error: expect(cropped_size).to be < 120
expected: < 120
got: 9476
# ./spec/models/optimized_image_spec.rb:27:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:279:in `block (2 levels) in <top (required)>'
Finished in 0.22966 seconds (files took 2.89 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/models/optimized_image_spec.rb:10 # OptimizedImage.crop should produce cropped images (requires ImageMagick 7)
Randomized with seed 44957
$
معلومات التشخيص
هذا الفشل مرتبط بهذا السطر.
عند تشغيله مع Ruby 2.7.4 يعمل، لكن مع Ruby 3.0.2 يظهر خطأ “لا يمكن تحويل ImageOptim::Timer إلى Float (TypeError)”. فيما يلي الخطوات الدنيا لتكرار المشكلة.
$ more foo.rb
gem 'image_optim'
require 'image_optim'
timeout = ImageOptim::Timer.new(15.0)
args = [{"PATH"=>
"/usr/bin"},
"date"
]
pid = Process.spawn(*args)
waiter = Process.detach(pid)
waiter.join(timeout)
- مع Ruby 3.0.2، يظهر “لا يمكن تحويل ImageOptim::Timer إلى Float (TypeError)”
$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
$ ruby foo.rb
foo.rb:14:in `join': can't convert ImageOptim::Timer into Float (TypeError)
from foo.rb:14:in `<main>'
Fri Oct 1 12:42:51 PM JST 2021
$
- مع Ruby 2.7.4 يعمل دون أي استثناء.
$ ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
$ ruby foo.rb
Fri Oct 1 12:44:00 PM JST 2021
$