From 1cf7b6e28ed846a92e8be7d2bd1b8878f7da14c9 Mon Sep 17 00:00:00 2001 From: Andrew McDonough Date: Mon, 9 May 2011 17:30:36 +0100 Subject: [PATCH 1/2] more specs --- spec/golf_spec.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/spec/golf_spec.rb b/spec/golf_spec.rb index cc0ab0d..180fb3e 100644 --- a/spec/golf_spec.rb +++ b/spec/golf_spec.rb @@ -6,21 +6,24 @@ it "should multiply the numbers in an array" do Golf.hole1([1,2,3,4]).should eql 24 end - it "should be 600 for [5,2,10,6]" do Golf.hole1([5,2,10,6]).should eql 600 end + it "should be 50 for [2,5,5]" do + Golf.hole1([2,5,5]).should eql 50 + end end - describe ".hole2" do it "should sort a sentence by the second letter of each word" do Golf.hole2("the quick brown fox").should eql "the fox brown quick" end - it "should successfully sort 'jumps over the lazy dog'" do Golf.hole2("jumps over the lazy dog").should eql "lazy the dog jumps over" end + it "should successfully sort 'ruby golf is great'" do + Golf.hole2("ruby golf is great").should eql "golf great is ruby" + end end describe ".hole3" do @@ -91,6 +94,16 @@ end end + describe ".hole7" do + it "should collapse consecutive numbers to a range" do + Golf.hole7([1,2,3]).should eql ["1-3"] + end + + it "should keep separate ranges distinct" do + Golf.hole7([1,2,3,5,6,7,100,101]).should eql ["1-3","5-7","100-101"] + end + end + describe ".hole8" do it "should give the first N numbers of the fibonacci sequence" do From f83b42b0cdcd8ae81d2fe149f4cb29125914f10c Mon Sep 17 00:00:00 2001 From: Simon Coffey Date: Mon, 9 May 2011 17:31:29 +0100 Subject: [PATCH 2/2] Ranges question --- spec/golf_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/golf_spec.rb b/spec/golf_spec.rb index 180fb3e..7af73a4 100644 --- a/spec/golf_spec.rb +++ b/spec/golf_spec.rb @@ -105,6 +105,21 @@ end + describe ".hole7" do + it "should collapse consecutive numbers to a range" do + Golf.hole7([1,2,3]).should eql ["1-3"] + end + + it "should keep separate ranges distinct" do + Golf.hole7([1,2,3,5,6,7,100,101]).should eql ["1-3","5-7","100-101"] + end + + it "should show isolated digits on their own" do + Golf.hole7([1,2,3,5,10,11,12]).should eql ["1-3","5","10-12"] + end + end + + describe ".hole8" do it "should give the first N numbers of the fibonacci sequence" do Golf.hole8(5).should eql [1,1,2,3,5]