Sha256: 66aacbc57a8c33f60466e70e1610f4de882c138d30e7055c7f6a1905cbffc8cb

Contents?: true

Size: 657 Bytes

Versions: 23

Compression:

Stored size: 657 Bytes

Contents

describe "String#gsub with pattern and replacement" do
  it "returns a copy of self with all occurrences of pattern replaced with replacement" do
    "hello".gsub(/[aeiou]/, '*').should == "h*ll*"
  end

  it "ignores a block if supplied" do
    "food".gsub(/f/, "g") { "w" }.should == "good"
  end
end

describe "String#gsub with pattern and block" do
  it "returns a copy of self with all occurrences of pattern replaced with the block's return value" do
    "hello".gsub(/./) { |s| s.succ + ' ' }.should == "i f m m p "
    "hello!".gsub(/(.)(.)/) { |*a| a.inspect }.should == '["he"]["ll"]["o!"]'
    "hello".gsub('l') { 'x'}.should == 'hexxo'
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.3.43 spec/rubyspec/core/string/gsub_spec.rb
opal-0.3.42 spec/core/string/gsub_spec.rb
opal-0.3.41 spec/core/string/gsub_spec.rb
opal-0.3.40 spec/core/string/gsub_spec.rb
opal-0.3.39 spec/core/string/gsub_spec.rb
opal-0.3.38 spec/core/string/gsub_spec.rb
opal-0.3.37 spec/core/string/gsub_spec.rb
opal-0.3.36 spec/core/string/gsub_spec.rb
opal-0.3.35 spec/core/string/gsub_spec.rb
opal-0.3.34 spec/core/string/gsub_spec.rb
opal-0.3.33 spec/core/string/gsub_spec.rb
opal-0.3.32 spec/core/string/gsub_spec.rb
opal-0.3.31 spec/core/string/gsub_spec.rb
opal-0.3.30 spec/core/string/gsub_spec.rb
opal-0.3.29 spec/core/string/gsub_spec.rb
opal-0.3.28 spec/core/string/gsub_spec.rb
opal-0.3.27 spec/core/string/gsub_spec.rb
opal-0.3.26 spec/core/string/gsub_spec.rb
opal-0.3.25 spec/core/string/gsub_spec.rb
opal-0.3.22 spec/core/string/gsub_spec.rb