Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use String#bytesize on Ruby 1.9

  • Loading branch information...
commit c668b143c449df11266797c1249c90cd4d965404 1 parent 7f855ff
@nurse nurse authored
Showing with 16 additions and 5 deletions.
  1. +16 −5 optional/capi/string_spec.rb
View
21 optional/capi/string_spec.rb
@@ -477,11 +477,22 @@ def to_str
@s.rb_str_resize_RSTRING_LEN("test", 2).should == 2
end
- it "increases the size of the string" do
- str = @s.rb_str_resize("test", 12)
- str.size.should == 12
- @s.RSTRING_LEN(str).should == 12
- str[0, 4].should == "test"
+ ruby_version_is ""..."1.9" do
+ it "increases the size of the string" do
+ str = @s.rb_str_resize("test", 12)
@brixen Owner
brixen added a note

Could we not use the encode() helper, which is already 1.8/1.9 compatible to encode to us-ascii and avoid needing this version guard?

The only reason this fails is that the random bytes beyond the current "test" could be, well, random.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ str.size.should == 12
+ @s.RSTRING_LEN(str).should == 12
+ str[0, 4].should == "test"
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "increases the size of the string" do
+ str = @s.rb_str_resize("test", 12)
+ str.bytesize.should == 12
+ @s.RSTRING_LEN(str).should == 12
+ str[0, 4].should == "test"
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.