From 13280922a5e6f993fbabf277788d79e6e0dea59e Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Thu, 12 Oct 2017 22:27:50 +0300 Subject: [PATCH 1/2] Add simple test for `capacity` argument of `String.new` method --- core/string/new_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/string/new_spec.rb b/core/string/new_spec.rb index 0a246f6f53..a8aa388035 100644 --- a/core/string/new_spec.rb +++ b/core/string/new_spec.rb @@ -15,6 +15,12 @@ end end + ruby_version_is "2.4" do + it "accepts a capacity argument" do + lambda { String.new("", capacity: 100_000) }.should_not raise_error + end + end + it "returns a fully-formed String" do str = String.new str.size.should == 0 From 96d735ef39aadcc76152dba3ec9534a0cb30e8cc Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Sat, 14 Oct 2017 16:41:39 +0300 Subject: [PATCH 2/2] Code review. Check string content instead of not raising exception --- core/string/new_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/string/new_spec.rb b/core/string/new_spec.rb index a8aa388035..b429ac48d2 100644 --- a/core/string/new_spec.rb +++ b/core/string/new_spec.rb @@ -17,7 +17,8 @@ ruby_version_is "2.4" do it "accepts a capacity argument" do - lambda { String.new("", capacity: 100_000) }.should_not raise_error + String.new("", capacity: 100_000).should == "" + String.new("abc", capacity: 100_000).should == "abc" end end