Skip to content

Commit

Permalink
Fix param for experimental ractor
Browse files Browse the repository at this point in the history
  • Loading branch information
ohbarye committed Apr 28, 2024
1 parent 4478729 commit 9db4ee7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pbt/check/rspec_adapter/property_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ def teardown_rspec_integration
# @param val [Object]
# @return [Ractor]
def run_in_ractor(val)
Ractor.new(@class_name, @method_name, val) do |class_name, method_name, val|
Ractor.new(@class_name, @method_name, @predicate.parameters.size, val) do |class_name, method_name, param_size, val|
klass = RSpecAdapter.const_get(class_name)
if val.is_a?(Hash)
klass.new.send(method_name, **val)
else
elsif param_size >= 2
klass.new.send(method_name, *val)
else
klass.new.send(method_name, val)
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/pbt/check/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@
end
end

Pbt.assert num_runs: 5, worker: :ractor, experimental_ractor_rspec_integration: true do
Pbt.property(Pbt.array(Pbt.integer, empty: false)) do |nums|
expect(nums).to be_a(Array)
expect(nums[0]).to be_a(Integer)
end
end

Pbt.assert num_runs: 5, worker: :ractor, experimental_ractor_rspec_integration: true do
Pbt.property(x: Pbt.integer, y: Pbt.integer) do |x:, y:|
expect(x + y).to be_a(Integer)
Expand Down

0 comments on commit 9db4ee7

Please sign in to comment.