Permalink
Browse files

Version7

I thought it would be neat to be able to enter a room from just a room
name, as well as a Room object.
  • Loading branch information...
jenkoian committed Oct 6, 2014
1 parent bc7dc08 commit f68fd0975ead6a6a1177732491ed3d29ba021880
Showing with 11 additions and 21 deletions.
  1. +5 −1 spec/Jenko/House/HouseSpec.php
  2. +6 −2 src/Jenko/House/House.php
  3. +0 −18 tests/contexts/HomeOwnerContext.php
@@ -40,7 +40,7 @@ function it_should_build_with_locations()
function it_should_set_location()
{
$location = Room::named('garage');
$location = Room::named('living room');
$this->setLocation($location);
$this->whereAmI()->shouldBe($location);
@@ -50,5 +50,9 @@ function it_should_allow_entering_rooms()
{
$room = Room::named('kitchen');
$this->enterRoom($room);
$this->whereAmI()->shouldBe($room);
$this->enterRoom('living room');
$this->whereAmI()->getName()->shouldBe('living room');
}
}
@@ -59,10 +59,14 @@ public function whereAmI()
}
/**
* @param Location $room
* @param Room|string $room
*/
public function enterRoom(Location $room)
public function enterRoom($room)
{
if (!$room instanceof Room && is_string($room)) {
$room = Room::named($room);
}
$this->currentLocation = $room;
}
}
@@ -132,22 +132,4 @@ public function iShouldNotBeAbleToEnterTheRoom($roomName)
return true;
}
}
/**
* @Then I should have room size and adjacent rooms
*/
public function iShouldHaveRoomSizeAndAdjacentRooms()
{
$information = $this->house->whereAmI()->getInformation();
PHPUnit_Framework_Assert::assertArrayHasKey('dimensions', $information);
PHPUnit_Framework_Assert::assertArrayHasKey('exits', $information);
}
/**
* @Given I am in the hallway
*/
public function iAmInTheHallway()
{
$this->iEnterTheRoom('hallway');
}
}

0 comments on commit f68fd09

Please sign in to comment.