Sha256: a2ff53319365ba2fbb590724db9b187783b9e83ae7b3e1ab11ba4f06d4cd4a24

Contents?: true

Size: 856 Bytes

Versions: 5

Compression:

Stored size: 856 Bytes

Contents

require File.dirname(__FILE__) + '/../../../lib/cucumber/core_ext/string'

describe String, "#gzub" do
  it "should format groups with format string" do
    "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/, "<span>%s</span>").should ==
    "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
  end

  it "should format groups with format string when there are dupes" do
    "I bob 1 bo this bobs".gzub(/I (\w+) (\d+) (\w+) this (\w+)/, "<span>%s</span>").should ==
    "I <span>bob</span> <span>1</span> <span>bo</span> this <span>bobs</span>"
  end

  it "should format groups with block" do
    f = "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/) do |m|
      "<span>#{m}</span>"
    end
    f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aslakhellesoy-cucumber-0.0.1 spec/cucumber/core_ext/string_spec.rb
aslakhellesoy-cucumber-0.1.1 spec/cucumber/core_ext/string_spec.rb
aslakhellesoy-cucumber-0.1.2 spec/cucumber/core_ext/string_spec.rb
aslakhellesoy-cucumber-0.1.3 spec/cucumber/core_ext/string_spec.rb
aslakhellesoy-cucumber-0.1.4 spec/cucumber/core_ext/string_spec.rb