Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Commits on Sep 14, 2012
  1. Describe and implement last step in scenario

    authored
    $> vim src/Bossa/Bundle/TrainingBundle/Features/Context/StudentContext.php
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    $> vim src/Bossa/Bundle/TrainingBundle/Resources/views/Courses/list.html.twig
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    
    Describe outcome expectations and tuneup the template to make scenario green.
  2. Add template to make scenario step green

    authored
    $> vim src/Bossa/Bundle/TrainingBundle/Resources/views/Courses/list.html.twig
    
    Added template to mark scenario green.
  3. Doing couple of scenario cycles about our entity

    authored
    $> vim behat.yml
    We've enabled page showing in extension for more output
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    We've ran scenario and it sais "No Bossa entity namespace"
    $> vim app/config/config.yml
    So we're adding configuration to the config.yml
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    We're running scenario again to discover "Directory does not exist"
    $> mkdir src/Bossa/Entity
    So we've created it
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    And then scenario started to complain about "No class"
    $> bin/phpspec describe Bossa/Entity/Course
    So we've described it
    $> bin/phpspec run
    And checked it. PHPSpec2 was nice enough to generate class for us
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    Then Doctrine2 inside scenario, started to complain that there's no mapping
    $> vim spec/Bossa/Entity/Course.php
    So we've added entity mapping
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    Then, scenario said "No primary key"
    $> vim spec/Bossa/Entity/Course.php
    So we've added getter for property and property example into spec
    $> bin/phpspec run
    And PHPSpec2 again was nice enough to generate method for us.
    $> vim spec/Bossa/Entity/Course.php
    We just needed to add property and its mapping.
    $> bin/behat --no-paths admissions/student_enrols_on_a_course.feature:6
    And we checked that we have no-Doctrine2 exception now
    
    We're going couple of scenario exception cycles to completely get rid
    of Doctrine exceptions. This is called "Change the message or make it
    green".
  4. Finish describing controller

    authored
    $> vim spec/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
    $> bin/phpspec run
    $> vim src/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
    $> bin/phpspec run
    
    We add final 3rd example to the controller specification. Which describes
    how we bring the data into the view.
  5. Add view rendering example to the controller specification

    authored
    $> vim spec/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
    $> bin/phpspec run
    $> vim src/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
    
    On this stage, we're describing what we're basically expecting from our
    controller - to render some view template with specific values. And
    making this example green.
  6. Start describing controller

    authored
    copy gist to spec/ControllerSpecification.php
    $> bin/phpspec describe Bossa/Bundle/TrainingBundle/Controller/CoursesController
    $> cat spec/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
    $> bin/phpspec run
    $> vim spec/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
    $> bin/phpspec run
    $> vim src/Bossa/Bundle/TrainingBundle/Controller/CoursesController.php
    
    We have a failing scenario, and we feel we need to add some code. It's time
    to introduce our first spec. We install phpspec and tell it we want to
    describe our controller. PHPSpec will create the controller specification
    and it will generates the required code for us. We will then just add the
    relevant behaviour we are expecting and make it green.'
  7. @MarcelloDuarte

    Implement second step definition

    MarcelloDuarte authored
    $> vim src/Bossa/Bundle/TrainingBundle/Features/Context/StudentContext.php
    $> vim app/config/routing.yml
    
    In implementing the visiting pages step we recommend that you take advantage
    of expressive route names. That forces us to add the route in the
    configuration. Because no class is required, no specs are written. Making sure
    you visit the url and that the route exists is not enough though. You need to
    know that the status returned is 200. Which takes us to implementing the
    controller that will handle that route.
  8. Implement first step definition

    authored
    $> vim src/Bossa/Bundle/TrainingBundle/Features/Context/StudentContext.php
    $> vim src/Bossa/Bundle/TrainingBundle/Features/Context/FeatureContext.php
    
    We implement `there are no courses scheduled` step definition. But, as we
    know that application state is clean at the beginning of each scenario,
    we're just removing `PendingException` from step definition, marking it
    as passed. Still in this case, we need to make sure, that we have clean
    application state before each scenario, so we're adding `@BeforeScenario`
    hook to purge database with `doctrine/data-fixtures` package.
  9. @MarcelloDuarte

    Prepare context files

    MarcelloDuarte authored
    $> bin/behat --append-snippets
    $> vim src/Bossa/Bundle/TrainingBundle/Features/Context/FeatureContext.php
    $> vim src/Bossa/Bundle/TrainingBundle/Features/Context/StudentContext.php
    
    By running --append-snippets behat will generate the code you need inside your
    feature context. It's good practice to keep the default FeatureContext slim
    and extract a context per roles in the system. The reason is again
    communication. The steps are read in the first person pointing to that role.
    The context should not extend BaseMink context. It should rather implement
    MinkAwareInterface, so you will be able to use mink directly inside your
    step definitions.
  10. Configure Behat and its extensions and fix bundle name

    authored
    rename BossaBundleTrainingBundle
    rename BossaBundleTrainingExtension
    $> vim app/AppKernel.php
    $> vim app/autoload.php
    $> vim behat.yml
    $> bin/behat --init BossaTrainingBundle
    $> bin/behat
    
    First, we fix broken bundle name, because of generator.
    Next, we're configuring our `behat.yml` and updating
    app/autoload.php to support in-Behat initialization.
    Then, we generate feature suite for our bundle.
  11. Add some scenarios

    authored
    $> vim src/Bossa/Bundle/TrainingBundle/Features/admissions/student_enrols_on_a_course.feature
    
    We are adding just enough scenarios to go over the steps of full stack bdd
    with Symfony. Please note that the order of the scenarios is important. They
    should ease the conversation. They should be fluid, meaning current scenario
    should expand the knowledge of previous one and prepare the conversation for
    the next one. They should be focused on the domain. They should focus on
    value and provide the "what do we mean" for the feature narrative.
  12. @MarcelloDuarte

    Create bundle and the first feature narrative

    MarcelloDuarte authored
    $> app/console generate:bundle -n --namespace Bossa/Bundle/TrainingBundle --dir src
    $> mkdir -p src/Bossa/Bundle/TrainingBundle/Features/admissions
    $> vim src/Bossa/Bundle/TrainingBundle/Features/admissions/student_enrols_on_a_course.feature
    
    We don't need Behat for starting the conversation. We can jump into describing
    the features. Features folder go under the root of the bundle. Inside the
    Features folder we create as many folders as features we will have. The will
    group the .feature files that contain the different user stories and scenarios
    for that feature.
  13. Remove AcmeDemoBundle and chmod app/console

    authored
    $> vim app/AppKernel.php
    $> vim app/config/routing_dev.yml
    $> chmod +x app/console
    $> rm -rf src/Acme
  14. Bootstrap Symfony2 project

    authored
    $> composer create-project symfony/framework-standard-edition fullstack-bdd-uk12 2.1.1
    $> cd fullstack-bdd-uk12
    $> vim composer.json
    $> composer install --dev
    
    First stage of project development - bootstraping. On this stage, we're
    creating Symfony2 Standard Edition project and declaring some dependencies
    that we will need to use during development:
    
    * doctrine/data-fixtures - to use purger, that will clean database for us
    * behat/behat - to describe business requirements for the project
    * behat/mink-extension - to test business requirements through web UI
    * behat/mink-browserkit-driver - to use Symfony2 driver in Mink
    * behat/symfony2-extension - to integrate Behat with Symfony2
    * phpspec/phpspec2 - to describe code-level specifications
Something went wrong with that request. Please try again.