From 159fde9c0242d1f32e1833ed13e4171f1a0cef16 Mon Sep 17 00:00:00 2001 From: hana-da Date: Fri, 25 Mar 2022 16:53:38 +0900 Subject: [PATCH 1/2] Fix "warning: instance variable @parameter not initialized" raised when `--warnings` are enabled --- lib/rspec/parameterized.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rspec/parameterized.rb b/lib/rspec/parameterized.rb index 53a2989..2f1f93e 100644 --- a/lib/rspec/parameterized.rb +++ b/lib/rspec/parameterized.rb @@ -77,6 +77,7 @@ def with_them(*args, &b) opts = args.last.is_a?(Hash) ? args.pop : {} opts[:caller] = caller unless opts[:caller] args.push(opts) + @parameter ||= nil if @parameter.nil? @parameterized_pending_cases ||= [] From 1ef3f3421d7503a2aa97424759ca4d4105f32742 Mon Sep 17 00:00:00 2001 From: hana-da Date: Fri, 25 Mar 2022 17:00:10 +0900 Subject: [PATCH 2/2] Fix "warning: instance variable @parameterized_pending_cases not initialized" raised when `--warnings` are enabled --- lib/rspec/parameterized.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/rspec/parameterized.rb b/lib/rspec/parameterized.rb index 2f1f93e..2bb5977 100644 --- a/lib/rspec/parameterized.rb +++ b/lib/rspec/parameterized.rb @@ -90,12 +90,11 @@ def with_them(*args, &b) private def set_parameters(arg_names, &b) @parameter = Parameter.new(arg_names, &b) + @parameterized_pending_cases ||= [] - if @parameterized_pending_cases - @parameterized_pending_cases.each { |e| - define_cases(@parameter, *e[0], &e[1]) - } - end + @parameterized_pending_cases.each { |e| + define_cases(@parameter, *e[0], &e[1]) + } end def define_cases(parameter, *args, &block)