Skip to content

Commit 7ad6178

Browse files
committed
Use binding_of_caller instead of binding_ninja
(cherry picked from commit 0760ea6ca93eaabbe1375ed6ff100ab0c131326e)
1 parent 2f78520 commit 7ad6178

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

lib/rspec/parameterized/table_syntax.rb

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

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

77
module RSpec
88
module Parameterized
99
module TableSyntaxImplement
10-
extend BindingNinja
11-
12-
def |(where_binding, other)
13-
caller_instance = where_binding.receiver # get caller instance (ExampleGroup)
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)
1413

1514
if caller_instance.instance_variable_defined?(:@__parameter_table)
1615
table = caller_instance.instance_variable_get(:@__parameter_table)
@@ -24,42 +23,57 @@ def |(where_binding, other)
2423
row.add_param(other)
2524
table
2625
end
27-
auto_inject_binding :|
2826
end
2927

3028
module TableSyntax
31-
refine Object do
32-
include TableSyntaxImplement
33-
end
29+
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("3.2.0.rc1")
30+
refine Object do
31+
import_methods TableSyntaxImplement
32+
end
3433

35-
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create("2.4.0")
3634
refine Integer do
37-
include TableSyntaxImplement
35+
import_methods TableSyntaxImplement
36+
end
37+
38+
refine Array do
39+
import_methods TableSyntaxImplement
40+
end
41+
42+
refine NilClass do
43+
import_methods TableSyntaxImplement
44+
end
45+
46+
refine TrueClass do
47+
import_methods TableSyntaxImplement
48+
end
49+
50+
refine FalseClass do
51+
import_methods TableSyntaxImplement
3852
end
3953
else
40-
refine Fixnum do
54+
refine Object do
4155
include TableSyntaxImplement
4256
end
4357

44-
refine Bignum do
58+
refine Integer do
4559
include TableSyntaxImplement
4660
end
47-
end
4861

49-
refine Array do
50-
include TableSyntaxImplement
51-
end
62+
refine Array do
63+
include TableSyntaxImplement
64+
end
5265

53-
refine NilClass do
54-
include TableSyntaxImplement
55-
end
66+
refine NilClass do
67+
include TableSyntaxImplement
68+
end
5669

57-
refine TrueClass do
58-
include TableSyntaxImplement
59-
end
70+
refine TrueClass do
71+
include TableSyntaxImplement
72+
end
6073

61-
refine FalseClass do
62-
include TableSyntaxImplement
74+
refine FalseClass do
75+
include TableSyntaxImplement
76+
end
6377
end
6478
end
6579
end

0 commit comments

Comments
 (0)