Mega Code Archive

 
Categories / Ruby / Unit Test
 

Testing Word Separation

require 'test/unit' class String   def words     scan(/\w[\w\'\-]*/)   end end def test_words   assert_equal(%w{this is a test}, "this is a test".words)   assert_equal(%w{these are mostly words}, "these are, mostly, words".words) end