diff --git a/.standard.yml b/.standard.yml index 724cc806..00a5f829 100644 --- a/.standard.yml +++ b/.standard.yml @@ -1 +1 @@ -ruby_version: "2.5" +ruby_version: "3.0" diff --git a/lib/factory_bot/decorator.rb b/lib/factory_bot/decorator.rb index 3a3a2448..75074822 100644 --- a/lib/factory_bot/decorator.rb +++ b/lib/factory_bot/decorator.rb @@ -6,24 +6,12 @@ def initialize(component) @component = component end - if ::Gem::Version.new(::RUBY_VERSION) >= ::Gem::Version.new("2.7") - class_eval(<<~RUBY, __FILE__, __LINE__ + 1) - def method_missing(...) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing - @component.send(...) - end - - def send(...) - __send__(...) - end - RUBY - else - def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing - @component.send(name, *args, &block) - end + def method_missing(...) # rubocop:disable Style/MethodMissingSuper + @component.send(...) + end - def send(symbol, *args, &block) - __send__(symbol, *args, &block) - end + def send(...) + __send__(...) end def respond_to_missing?(name, include_private = false) diff --git a/lib/factory_bot/definition_proxy.rb b/lib/factory_bot/definition_proxy.rb index dc139ad5..a27c33f2 100644 --- a/lib/factory_bot/definition_proxy.rb +++ b/lib/factory_bot/definition_proxy.rb @@ -119,8 +119,8 @@ def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondTo # end # # Except that no globally available sequence will be defined. - def sequence(name, *args, &block) - sequence = Sequence.new(name, *args, &block) + def sequence(name, ...) + sequence = Sequence.new(name, ...) FactoryBot::Internal.register_inline_sequence(sequence) add_attribute(name) { increment_sequence(sequence) } end diff --git a/lib/factory_bot/evaluator.rb b/lib/factory_bot/evaluator.rb index 70e7ef28..7a4b82e7 100644 --- a/lib/factory_bot/evaluator.rb +++ b/lib/factory_bot/evaluator.rb @@ -35,14 +35,13 @@ def association(factory_name, *traits_and_overrides) attr_accessor :instance - def method_missing(method_name, *args, &block) + def method_missing(method_name, ...) if @instance.respond_to?(method_name) - @instance.send(method_name, *args, &block) + @instance.send(method_name, ...) else - SyntaxRunner.new.send(method_name, *args, &block) + SyntaxRunner.new.send(method_name, ...) end end - ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true) def respond_to_missing?(method_name, _include_private = false) @instance.respond_to?(method_name) || SyntaxRunner.new.respond_to?(method_name) diff --git a/lib/factory_bot/syntax/default.rb b/lib/factory_bot/syntax/default.rb index fd391d0c..66f4d2c7 100644 --- a/lib/factory_bot/syntax/default.rb +++ b/lib/factory_bot/syntax/default.rb @@ -25,8 +25,8 @@ def factory(name, options = {}, &block) end end - def sequence(name, *args, &block) - Internal.register_sequence(Sequence.new(name, *args, &block)) + def sequence(name, ...) + Internal.register_sequence(Sequence.new(name, ...)) end def trait(name, &block) diff --git a/spec/acceptance/attributes_for_destructuring.rb b/spec/acceptance/attributes_for_destructuring.rb index 0b06f386..2f10c33d 100644 --- a/spec/acceptance/attributes_for_destructuring.rb +++ b/spec/acceptance/attributes_for_destructuring.rb @@ -15,7 +15,7 @@ it "supports being destructured" do # rubocop:disable Lint/Syntax attributes_for(:user) => {name:, **attributes} - # rubocop:disable Lint/Syntax + # rubocop:enable Lint/Syntax expect(name).to eq("John Doe") expect(attributes.keys).to eq([:email]) diff --git a/spec/acceptance/attributes_for_spec.rb b/spec/acceptance/attributes_for_spec.rb index 575c77f1..624e0d90 100644 --- a/spec/acceptance/attributes_for_spec.rb +++ b/spec/acceptance/attributes_for_spec.rb @@ -1,5 +1,5 @@ -if RUBY_VERSION >= "3.0" && RUBY_ENGINE != "truffleruby" - require_relative "./attributes_for_destructuring" +if RUBY_ENGINE != "truffleruby" + require_relative "attributes_for_destructuring" end describe "a generated attributes hash" do