Skip to content

Commit

Permalink
fix string_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Sep 22, 2009
1 parent 76177f7 commit bb92a70
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions spec/cucumber/core_ext/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
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 bob 1 bo this bobs".gzub(%w{bob 1 bo bobs}, [2, 6, 8, 16], "<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|
f = "I ate 1 egg this morning".gzub(%w{ate 1 egg morning}, [2, 6, 8, 17]) do |m|
"<span>#{m}</span>"
end
f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
Expand All @@ -23,21 +23,14 @@
proc = lambda do |m|
"<span>#{m}</span>"
end
f = "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/, proc)
f = "I ate 1 egg this morning".gzub(%w{ate 1 egg morning}, [2, 6, 8, 17], proc)
f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
end

it "should format groups with block with not all placeholders having a value" do
f = "another member named Bob joins the group".gzub(/(a|another) (user|member) named ([^ ]+)( who is not logged in)?/) do |m|
f = "another member named Bob joins the group".gzub(%w{another member Bob}, [0, 8, 21]) do |m|
"<span>#{m}</span>"
end
f.should == "<span>another</span> <span>member</span> named <span>Bob</span> joins the group"
end

it "should format match groups in a textile table row" 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

0 comments on commit bb92a70

Please sign in to comment.