From d7c48f47a0c989bb54cc9b48b96a77fc77851a7e Mon Sep 17 00:00:00 2001 From: Luca Guidi Date: Thu, 26 Oct 2023 10:03:40 +0200 Subject: [PATCH] Introducing private API method: `Hanami::CLI::Generators::Context#ruby_implicity_keyword_argument?` --- lib/hanami/cli/generators/context.rb | 8 +++++++ .../hanami/cli/generators/context_spec.rb | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 spec/unit/hanami/cli/generators/context_spec.rb 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