Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extract String#bytesize shim

  • Loading branch information...
commit 7244425b93ded0789b73681533df84ffcd562852 1 parent 2102945
@jeremy jeremy authored
View
1  activesupport/lib/active_support/core_ext/string.rb
@@ -1,6 +1,7 @@
# encoding: utf-8
require 'active_support/core_ext/string/inflections'
+require 'active_support/core_ext/string/bytesize'
require 'active_support/core_ext/string/conversions'
require 'active_support/core_ext/string/access'
require 'active_support/core_ext/string/starts_ends_with'
View
5 activesupport/lib/active_support/core_ext/string/bytesize.rb
@@ -0,0 +1,5 @@
+unless '1.9'.respond_to?(:bytesize)
+ class String
+ alias :bytesize :size
+ end
+end
View
7 activesupport/test/core_ext/string_ext_test.rb
@@ -274,3 +274,10 @@ def test_mb_chars_returns_string
end
end
end
+
+class StringBytesizeTest < Test::Unit::TestCase
+ def test_bytesize
+ assert_respond_to 'foo', :bytesize
+ assert_equal 3, 'foo'.bytesize
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.