ohbarye / pbt

Property-Based Testing tool for Ruby, supporting multiple concurrency methods (Ractor, multiprocesses, multithreads).
https://rubygems.org/gems/pbt
MIT License
207 stars 4 forks source link

Allow to use RSpec matchers in Ractor #20

Closed ohbarye closed 5 months ago

ohbarye commented 5 months ago

Change

This pull request adds a quite experimental feature that allows users to use RSpec matchers (expect, eq etc.) in Ractor mode with experimental_ractor_rspec_integration: true.

The way to do that is a hack.

  1. Obtains a user-defined code block.
  2. Redefine the code as a method in a new class with class_eval.
  3. Pass the class name and method name to Ractor.
  4. Let Ractor instantiate the class and call the method.

That's it.

I might remove this feature in future since it's a quite dirty hack and unstable.