diff options
Diffstat (limited to 'features/step_definitions/mastermind.rb')
| -rw-r--r-- | features/step_definitions/mastermind.rb | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/features/step_definitions/mastermind.rb b/features/step_definitions/mastermind.rb index f07c541..680a2b6 100644 --- a/features/step_definitions/mastermind.rb +++ b/features/step_definitions/mastermind.rb @@ -1,24 +1,35 @@ # mastermind.rb +def messenger + @messenger ||= StringIO.new +end -Given /^I am not yet playing$/ do +def game + @game = ||= Mastermind::Game.new(messenger) end -When /^I start a new game$/ do - @messenger = StringIO.new - game =Mastermind::Game.new(@messenger) - game.start + +def messages_should_include(message) + messenger.string.split("\n").should include(message) end -Then /^the game should say "(.$)"$/ do |message| - @messenger.string.split("\n").should include(message) + +Given /^I am not yet playing$/ do end Given /^the secret code is (. . . .)$/ do |code| - @messenger = StringIO.new - @game = Mastermind::Game.new(@messenger) - @game.start(code.split) + game.start(code.split) end + When /^I guess (. . . .)$/ do |code| - @game.guess(code.split) + game.guess(code.split) end + +When /^I start a new game$/ do + game.start +end + +Then /^the game should say "(.$)"$/ do |message| + messages_should_include(message) +end + Then /^the mark should be (.*)$/ do |mark| - @messenger.string.split("\n").should include(mark) + messages_should_include(mark) end |
