Commit c5e9558
Changed files (8)
features
step_definitions
support
lib
mastermind
spec
mastermind
features/step_definitions/.mastermind.rb.swp
Binary file
features/step_definitions/mastermind.rb
@@ -5,7 +5,7 @@ end
When /^I start a new game$/ do
@messenger = StringIO.new
- Mastermind::Game.new(@messenger)
+ game =Mastermind::Game.new(@messenger)
game.start
end
features/support/env.rb
@@ -1,1 +1,4 @@
# env.rb
+$: << File.join(File.dirname(__FILE__), "/../../lib")
+require 'spec/expectations'
+require 'mastermind'
lib/mastermind/game.rb
@@ -0,0 +1,12 @@
+# game.rb
+module Mastermind
+ class Game
+ def initialize(messenger)
+ @messenger = messenger
+ end
+ def start
+ @messenger.puts "Welcome to Mastermind!"
+
+ end
+ end
+end
lib/mastermind.rb
@@ -1,1 +1,2 @@
# mastermind.rb
+require 'mastermind/game'
spec/mastermind/game_spec.rb
@@ -0,0 +1,15 @@
+# game_spec.rb
+require File.join(File.dirname(__FILE__), "/../spec_helper")
+
+module Mastermind
+ describe Game do
+ context "starting up" do
+ it "should send a welcome message" do
+ messenger = mock("messenger")
+ game = Game.new(messenger)
+ messenger.should_receive(:puts).with("Welcome to Mastermind!")
+ game.start
+ end
+ end
+ end
+end
spec/spec_helper.rb
@@ -1,1 +1,3 @@
-# spec_helper.rb
+$: << File.join(File.dirname(__FILE__), "/../lib")
+require 'spec'
+require 'mastermind'
.gitignore
@@ -1,1 +1,5 @@
+*.suo
+*.cache
+*~
*.swp
+*.swo