Skip to content

Commit

Permalink
Introducing private API method: `Hanami::CLI::Generators::Context#rub…
Browse files Browse the repository at this point in the history
…y_implicity_keyword_argument?` (#118)
  • Loading branch information
jodosha authored Oct 26, 2023
1 parent dd049fd commit 200b5f6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/hanami/cli/generators/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions spec/unit/hanami/cli/generators/context_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 200b5f6

Please sign in to comment.