Permalink
Browse files

Version12

Adding steps for checking dimensions and exits are available. These
weren't explicit in our initial conversation but through working through
the model and subsequent (ok fake in this case) conversations with the
client it's now apparant that dimensions and exits are part of this
model. In true DDD style, making the implicit, explicit.
  • Loading branch information...
jenkoian committed Jan 19, 2015
1 parent a81431f commit 802936f09a1c85c06c7b5b572f45d4e76b0b6b69
@@ -1,15 +1,22 @@
@home-owner @potential-buyer
Feature: Navigating the house
Feature: Home owner navigating the house
Scenario: Entering the house
Given I am in the "front garden"
When I enter through the front door
Then I should be in the "hallway"
Scenario: Getting room info
Given I am in the "hallway"
Given there are the following locations in the house
| name | type | width | height |
| front garden | garden | 300 | 300 |
| hallway | room | 300 | 300 |
| living room | room | 300 | 300 |
| kitchen | room | 300 | 300 |
And I am in the "hallway"
When I request room info
Then I should have dimensions and exits
Then I should have dimensions "300 x 300"
And I should have exits
Scenario: Leaving the house
Given I am in the "hallway"
@@ -28,4 +35,4 @@ Feature: Navigating the house
Scenario: Entering a room that doesn't exist
Given I am in the "hallway"
Then I should not be able to enter the "made up" room
Then I should not be able to enter the "made up" room
@@ -16,6 +16,7 @@ function let()
function it_is_initializable()
{
$this->shouldHaveType('Jenko\House\Garden');
$this->shouldHaveType('Jenko\House\Location');
}
function it_should_be_created_with_a_name()
@@ -37,4 +38,14 @@ function it_should_be_able_to_set_dimensions()
$this->getDimensions()->shouldEqual($dimensions);
}
function it_should_have_information_on_dimensions()
{
$dimensions = Dimensions::fromWidthAndHeight(350, 300);
$this->setDimensions($dimensions);
$info = $this->getInformation();
$info['dimensions']->shouldBe('350 x 300');
}
}
@@ -16,6 +16,7 @@ function let()
function it_is_initializable()
{
$this->shouldHaveType('Jenko\House\Room');
$this->shouldHaveType('Jenko\House\Location');
}
function it_should_be_created_with_a_name()
@@ -37,4 +38,14 @@ function it_should_be_able_to_set_dimensions()
$this->getDimensions()->shouldEqual($dimensions);
}
function it_should_have_information_on_dimensions()
{
$dimensions = Dimensions::fromWidthAndHeight(350, 300);
$this->setDimensions($dimensions);
$info = $this->getInformation();
$info['dimensions']->shouldBe('350 x 300');
}
}
@@ -65,4 +65,12 @@ public function getHeight()
{
return $this->height;
}
/**
* @return string
*/
public function __toString()
{
return $this->getWidth() . ' x ' . $this->getHeight();
}
}
@@ -35,7 +35,7 @@ public function getName()
*/
public function getInformation()
{
return ['dimensions' => '', 'exits' => ''];
return ['dimensions' => (string)$this->getDimensions(), 'exits' => ''];
}
/**
@@ -1,5 +1,6 @@
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\TableNode;
@@ -29,13 +30,7 @@ public function __construct()
*/
public function iAmInThe($location)
{
if (false !== strpos($location, 'garden')) {
$location = Room::named($location);
} else {
$location = Garden::named($location);
}
$this->house->setLocation($location);
$this->iEnterTheRoom($location);
}
/**
@@ -134,4 +129,24 @@ public function iShouldNotBeAbleToEnterTheRoom($roomName)
return true;
}
}
/**
* @Then I should have dimensions :dimensions
*/
public function iShouldHaveDimensions($dimensions)
{
$information = $this->house->whereAmI()->getInformation();
PHPUnit_Framework_Assert::assertArrayHasKey('dimensions', $information);
PHPUnit_Framework_Assert::assertEquals($dimensions, $information['dimensions']);
}
/**
* @Then I should have exits
*/
public function iShouldHaveExits()
{
$information = $this->house->whereAmI()->getInformation();
PHPUnit_Framework_Assert::assertArrayHasKey('exits', $information);
}
}

0 comments on commit 802936f

Please sign in to comment.