Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spec: Struct#keyword_init? #948

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/struct/keyword_init_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require_relative '../../spec_helper'

describe "Struct#keyword_init?" do
ruby_version_is '3.1' do # https://bugs.ruby-lang.org/issues/18008
it "returns true if it's initialized with keyword_init: true option" do
klass = Struct.new(:name, keyword_init: true)
klass.keyword_init?.should == true
end

it "returns false if it's initialized with keyword_init: false option" do
klass = Struct.new(:name, keyword_init: false)
klass.keyword_init?.should == false
end

it "returns nil if it's initialized without keyword_init option" do
klass = Struct.new(:name)
klass.keyword_init?.should == nil
end
end
end