summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2009-05-26 15:08:45 -0600
committermo khan <mo@mokhan.ca>2009-05-26 15:08:45 -0600
commitc5e95580396082f4038caac3837236895a16013d (patch)
treed8859ac161bb3f7b0d42429392516fb82e5c18fa
parentc47b71e4c3a0fe18d2eb705bd0e9b7c33e6b2e92 (diff)
end of page 45
-rw-r--r--.gitignore4
-rw-r--r--features/step_definitions/.mastermind.rb.swpbin12288 -> 12288 bytes
-rw-r--r--features/step_definitions/mastermind.rb2
-rw-r--r--features/support/env.rb3
-rw-r--r--lib/mastermind.rb1
-rw-r--r--lib/mastermind/game.rb12
-rw-r--r--spec/mastermind/game_spec.rb15
-rw-r--r--spec/spec_helper.rb4
8 files changed, 39 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 1377554..b849ce8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
+*.suo
+*.cache
+*~
*.swp
+*.swo
diff --git a/features/step_definitions/.mastermind.rb.swp b/features/step_definitions/.mastermind.rb.swp
index fcf7c1e..c466739 100644
--- a/features/step_definitions/.mastermind.rb.swp
+++ b/features/step_definitions/.mastermind.rb.swp
Binary files differ
diff --git a/features/step_definitions/mastermind.rb b/features/step_definitions/mastermind.rb
index 6427dcc..39540e8 100644
--- a/features/step_definitions/mastermind.rb
+++ b/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
diff --git a/features/support/env.rb b/features/support/env.rb
index bc85e4b..f739e82 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -1 +1,4 @@
# env.rb
+$: << File.join(File.dirname(__FILE__), "/../../lib")
+require 'spec/expectations'
+require 'mastermind'
diff --git a/lib/mastermind.rb b/lib/mastermind.rb
index 31484c1..9da5e1e 100644
--- a/lib/mastermind.rb
+++ b/lib/mastermind.rb
@@ -1 +1,2 @@
# mastermind.rb
+require 'mastermind/game'
diff --git a/lib/mastermind/game.rb b/lib/mastermind/game.rb
new file mode 100644
index 0000000..86ed115
--- /dev/null
+++ b/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
diff --git a/spec/mastermind/game_spec.rb b/spec/mastermind/game_spec.rb
new file mode 100644
index 0000000..e67cf85
--- /dev/null
+++ b/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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6841dfc..c516ebc 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1 +1,3 @@
-# spec_helper.rb
+$: << File.join(File.dirname(__FILE__), "/../lib")
+require 'spec'
+require 'mastermind'