aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-03 07:11:47 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-03 07:11:47 +0000
commit1e145099a78688d25f2cfcafe58afbd651bf7be4 (patch)
tree287ad1369fc08c1f8d17cb537b8be6a23fba5906 /activesupport/test/core_ext
parent89550ee7e90fa824c99cf4882426d9a5269d0d64 (diff)
downloadrails-1e145099a78688d25f2cfcafe58afbd651bf7be4.tar.gz
rails-1e145099a78688d25f2cfcafe58afbd651bf7be4.tar.bz2
rails-1e145099a78688d25f2cfcafe58afbd651bf7be4.zip
Added String#at, String#from, String#to, String#first, String#last in ActiveSupport::CoreExtensions::String::Access to ease access to individual characters and substrings in a string serving basically as human names for range access. Added easy extendability to the inflector through Inflector.inflections (using the Inflector::Inflections singleton class)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2110 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index f394509dd1..34d4057cf9 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -67,4 +67,18 @@ class StringInflectionsTest < Test::Unit::TestCase
assert_equal Time.local(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time(:local)
assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date
end
+
+ def test_access
+ s = "hello"
+ assert_equal "h", s.at(0)
+
+ assert_equal "llo", s.from(2)
+ assert_equal "hel", s.to(2)
+
+ assert_equal "h", s.first
+ assert_equal "he", s.first(2)
+
+ assert_equal "o", s.last
+ assert_equal "llo", s.last(3)
+ end
end