diff --git a/lib/hanami/cli/generators/context.rb b/lib/hanami/cli/generators/context.rb index 9b93d3eb..76ab8a96 100644 --- a/lib/hanami/cli/generators/context.rb +++ b/lib/hanami/cli/generators/context.rb @@ -92,6 +92,14 @@ def bundled_assets? Hanami.bundled?("hanami-assets") end + # @since 2.1.0 + # @api private + # + # @see https://rubyreferences.github.io/rubychanges/3.1.html#values-in-hash-literals-and-keyword-arguments-can-be-omitted + def ruby_implicity_keyword_argument? + RUBY_VERSION >= "3.1" + end + private # @since 2.0.0 diff --git a/spec/unit/hanami/cli/generators/context_spec.rb b/spec/unit/hanami/cli/generators/context_spec.rb new file mode 100644 index 00000000..8eecb9c7 --- /dev/null +++ b/spec/unit/hanami/cli/generators/context_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require "dry/inflector" + +RSpec.describe Hanami::CLI::Generators::Context do + subject { described_class.new(inflector, app) } + + let(:inflector) { Dry::Inflector.new } + let(:app) { double("app") } + + describe "#ruby_implicity_keyword_argument?" do + if RUBY_VERSION >= "3.1" + it "returns true" do + expect(subject.ruby_implicity_keyword_argument?).to be(true) + end + else + it "returns false" do + expect(subject.ruby_implicity_keyword_argument?).to be(false) + end + end + end +end