Commit da73fdb

mo khan <mo@mokhan.ca>
2009-05-27 14:33:24
added new feature when codebreaker submits a guess
1 parent 7e98093
Changed files (2)
features/step_definitions/mastermind.rb
@@ -12,3 +12,9 @@ end
 Then /^the game should say "(.$)"$/ do |message|
 	@messenger.string.split("\n").should include(message)
 end
+
+Given /^the secret code is (. . . .)$/ do |code|
+	@messenger = StringIO.new	
+	game = Mastermind::Game.new(@messenger)
+	game.start(code.split)
+end
features/codebreaker_submits_guess.feature
@@ -0,0 +1,43 @@
+Feature: code-breaker submits guess
+
+	The code-breaker submits a guess of four colored
+	pegs. The mastermind game marks the guess with black
+	and white "marker" pegs.
+
+	For each peg in the guess that matches color
+	and position of a peg in the secret code, the
+	mark includes one black peg. For each additional
+	peg in the guess that matches the color but not
+	the position of a color in the secret code, a
+	white peg is added ot the mark.
+
+	Scenario Outline: submit guess
+		Given the secret code is <code>
+		When I guess <guess>
+		Then the mark should be <mark>
+
+	Scenarios: all colors correct
+	| code		| guess		| mark	|
+	| r g y c	| r g y c	| bbbb	|
+	| r g y c	| r g c y	| bbww	|
+	| r g y c	| y r g c	| bwww	|
+	| r g y c	| c r g y	| wwww	|
+
+	Scenarios: 3 colors correct
+	| code		| guess		| mark	|
+	| r g y c	| w g y c	| bbb	|
+	| r g y c	| w r y c	| bbw	|
+	| r g y c	| w r g c	| bww	|
+	| r g y c	| w r g y	| www	|
+
+	Scenarios: 2 colors correct
+	| code		| guess		| mark	|
+	| r g y c	| w g w c	| bb	|
+	| r g y c	| w r w c	| bb	|
+	| r g y c	| g w c w	| bw	|
+	| r g y c	| w r g y	| ww	|
+
+	Scenarios: 1 color correct
+	| code		| guess		| mark	|
+	| r g y c	| r w w w	| b		|
+	| r g y c	| w w r w	| w		|