Permalink
Browse files

Looking around in one room

  • Loading branch information...
0 parents commit 86aef40c77120b2c000303df75568f5e82b4fe98 iain and ronald committed with Mar 1, 2012
Showing with 138 additions and 0 deletions.
  1. +3 −0 .rspec
  2. +1 −0 .rvmrc
  3. +4 −0 Gemfile
  4. +28 −0 Gemfile.lock
  5. +13 −0 features/items.feature
  6. +28 −0 features/steps/items.rb
  7. +1 −0 features/support/env.rb
  8. +15 −0 lib/game.rb
  9. +11 −0 lib/room.rb
  10. +5 −0 script/test
  11. +17 −0 spec/game_spec.rb
  12. +12 −0 spec/room_spec.rb
3 .rspec
@@ -0,0 +1,3 @@
+--color
+--format documentation
+--order rand
1 .rvmrc
@@ -0,0 +1 @@
+rvm 1.9.3@game
@@ -0,0 +1,4 @@
+source :rubygems
+
+gem 'spinach'
+gem 'rspec'
@@ -0,0 +1,28 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ colorize (0.5.8)
+ diff-lcs (1.1.3)
+ gherkin-ruby (0.1.0)
+ racc
+ rexical
+ racc (1.4.7)
+ rexical (1.0.5)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ spinach (0.3.1)
+ colorize
+ gherkin-ruby (~> 0.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rspec
+ spinach
@@ -0,0 +1,13 @@
+Feature: Items
+
+ Scenario: Looking around
+
+ Given I'm in a room with a rubber chicken
+ When I look around
+ Then I should see the rubber chicken
+
+ # Scenario: Picking up an object
+
+ # Given I'm in a room with a rubber chicken
+ # When I pick up the rubber chicken
+ # Then I should have the rubber chicken in my inventory
@@ -0,0 +1,28 @@
+require 'room'
+require 'game'
+
+class ItemsSteps < Spinach::FeatureSteps
+ feature 'Items'
+
+ Given "I'm in a room with a rubber chicken" do
+ @room = Room.new(items: [:rubber_chicken])
+ @game = Game.new(rooms: [@room])
+ end
+
+ When 'I look around' do
+ @output = @game.look
+ end
+
+ Then 'I should see the rubber chicken' do
+ @output.should == [:rubber_chicken]
+ end
+
+ When 'I pick up the rubber chicken' do
+ raise 'step not implemented'
+ end
+
+ Then 'I should have the rubber chicken in my inventory' do
+ raise 'step not implemented'
+ end
+
+end
@@ -0,0 +1 @@
+require 'rspec'
@@ -0,0 +1,15 @@
+class Game
+
+ def initialize(options)
+ @options = options
+ end
+
+ def rooms
+ @options[:rooms]
+ end
+
+ def look
+ rooms.first.look
+ end
+
+end
@@ -0,0 +1,11 @@
+class Room
+
+ def initialize(options)
+ @options = options
+ end
+
+ def look
+ @options[:items]
+ end
+
+end
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -e
+
+rspec
+spinach
@@ -0,0 +1,17 @@
+require 'game'
+
+describe Game do
+
+ let(:room) { stub }
+ subject { Game.new(rooms: [room]) }
+
+ it "can be started with rooms" do
+ subject.should have(1).rooms
+ end
+
+ specify "looking around" do
+ room.should_receive(:look)
+ subject.look
+ end
+
+end
@@ -0,0 +1,12 @@
+require 'room'
+
+describe Room do
+
+ let(:item) { stub }
+ subject { Room.new(items: [item]) }
+
+ specify "looking around" do
+ subject.look.should == [item]
+ end
+
+end

0 comments on commit 86aef40

Please sign in to comment.