Skip to content

Commit 2f78520

Browse files
joker1007sue445
authored andcommitted
Replace binding_of_caller with binding_ninja
(cherry picked from commit d58fee6ccfb91f66c111075d48e7da308090225b)
1 parent 4d143c1 commit 2f78520

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/rspec/parameterized/table_syntax.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# frozen_string_literal: true
22

33
require_relative "table_syntax/version"
4-
require 'binding_of_caller'
54
require 'rspec/parameterized/table'
5+
require 'binding_ninja'
66

77
module RSpec
88
module Parameterized
99
module TableSyntaxImplement
10-
def |(other)
11-
where_binding = binding.of_caller(1) # get where block binding
12-
caller_instance = eval("self", where_binding) # get caller instance (ExampleGroup)
10+
extend BindingNinja
11+
12+
def |(where_binding, other)
13+
caller_instance = where_binding.receiver # get caller instance (ExampleGroup)
1314

1415
if caller_instance.instance_variable_defined?(:@__parameter_table)
1516
table = caller_instance.instance_variable_get(:@__parameter_table)
@@ -23,6 +24,7 @@ def |(other)
2324
row.add_param(other)
2425
table
2526
end
27+
auto_inject_binding :|
2628
end
2729

2830
module TableSyntax

0 commit comments

Comments
 (0)