Skip to content

Commit

Permalink
pass test for exact match
Browse files Browse the repository at this point in the history
  • Loading branch information
Eben Geer committed Mar 6, 2012
1 parent c4f89e2 commit e6ed4f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion codebreaker.rb
Expand Up @@ -11,7 +11,9 @@ def start(secret)
end

def guess(guess)
if @secret.include?(guess[0])
if guess[0] == @secret[0]
mark = '+'
elsif @secret.include?(guess[0])
mark = '-'
else
mark = ''
Expand Down
8 changes: 8 additions & 0 deletions spec/codebreaker_spec.rb
Expand Up @@ -34,6 +34,14 @@ module Codebreaker
game.guess('2555')
end
end

context "with 1 exact match" do
it "sends a mark with '+'" do
game.start('1234')
output.should_receive(:puts).with('+')
game.guess('1555')
end
end
end
end
end

0 comments on commit e6ed4f5

Please sign in to comment.