Skip to content

Instantly share code, notes, and snippets.

@vertiginous
Created January 17, 2011 21:50
Show Gist options
  • Select an option

  • Save vertiginous/783552 to your computer and use it in GitHub Desktop.

Select an option

Save vertiginous/783552 to your computer and use it in GitHub Desktop.
def parse(name)
raise "Write the parse method."
end
describe "parse" do
it "should list all permutations, text in brackets is optional" do
strings = parse("foo[bar]")
strings.should include('foo')
strings.should include('foobar')
strings.should_not include('bar')
strings.size.should == 2
end
it "should list all permutations, text in brackets is optional" do
strings = parse("[foo]bar")
strings.should include('bar')
strings.should include('foobar')
strings.should_not include('foo')
strings.size.should == 2
end
it "should list all permutations, text in brackets is optional" do
strings = parse("[foo]bar[baz]")
strings.should include('foobar')
strings.should include('bar')
strings.should include('barbaz')
strings.should include('foobarbaz')
strings.should_not include('foo')
strings.should_not include('baz')
strings.size.should == 4
end
it "should return the string, when there are no brackets" do
strings = parse("foo")
strings.should include('foo')
strings.size.should == 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment