Skip to content
Browse files

Added taunts (are output each turn if a player responds to #taunt wit…

…h a non-empty string)
  • Loading branch information...
1 parent 2a279c2 commit 19d62eebb509d3a841f002b66553986e8421b2e8 @gareth gareth committed Jun 29, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/console_renderer.rb
  2. +9 −0 spec/lib/console_renderer_spec.rb
View
2 lib/console_renderer.rb
@@ -62,7 +62,7 @@ def game_frame(states)
clear
states.each do |state|
- output state.player.name
+ output "%s%s" % [state.player.name, (%{ - "#{state.player.taunt}"} if state.player.respond_to?(:taunt) && state.player.taunt.to_s.length > 0)]
output state.current_pattern
output "Correct: #{state.correct_guesses.join(' ')}"
output "Incorrect: #{state.incorrect_guesses.join(' ')}"
View
9 spec/lib/console_renderer_spec.rb
@@ -82,6 +82,15 @@
@renderer.game_frame(@states)
end
+ it "for each player state it should render their name and taunt if present" do
+ @player.class.instance_eval do
+ define_method(:taunt) { "Go on!" }
+ end
+ @renderer.should_receive(:output).with(%{Andy's Awesome Player - "Go on!"})
+
+ @renderer.game_frame(@states)
+ end
+
it "for each player state it should render the state of their current pattern" do
@renderer.should_receive(:output).with("___/___/___")

0 comments on commit 19d62ee

Please sign in to comment.
Something went wrong with that request. Please try again.