Sha256: 6d194fdb46aeacbc84da5809e3507fc5ec724e192afafd11e066105ef6bca3fe

Contents?: true

Size: 700 Bytes

Versions: 16

Compression:

Stored size: 700 Bytes

Contents

require 'helper'

class TestGsub < Test::Unit::TestCase
  
  context "Applying gsub_each to string" do

    should "pass match info to a block and use result for substitution" do
      assert_equal "xxx AXA yue asx AYA AZA", "xxx axa yue asx aya aza".gsub_each(/a.a/){|match| match.to_s.upcase}
    end

    should "not modify the string" do
      str = "xxx axa yue asx aya aza"
      str.gsub_each(/a.a/){|match| match.to_s.upcase}
      assert_equal "xxx axa yue asx aya aza", str
    end

    should "have a mutator version" do
      str = "xxx axa yue asx aya aza"
      str.gsub_each!(/a.a/){|match| match.to_s.upcase}
      assert_equal "xxx AXA yue asx AYA AZA", str
    end
    
  end
  
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
modalsupport-0.9.2 test/test_gsub.rb
modalsupport-0.9.1 test/test_gsub.rb
modalsupport-0.9.0 test/test_gsub.rb
modalsupport-0.8.3 test/test_gsub.rb
modalsupport-0.8.2 test/test_gsub.rb
modalsupport-0.8.1 test/test_gsub.rb
modalsupport-0.8.0 test/test_gsub.rb
modalsupport-0.7.1 test/test_gsub.rb
modalsupport-0.7.0 test/test_gsub.rb
modalsupport-0.6.0 test/test_gsub.rb
modalsupport-0.5.2 test/test_gsub.rb
modalsupport-0.5.1 test/test_gsub.rb
modalsupport-0.5.0 test/test_gsub.rb
modalsupport-0.4.0 test/test_gsub.rb
modalsupport-0.3.0 test/test_gsub.rb
modalsupport-0.2.0 test/test_gsub.rb