2017 © Pedro Peláez
 

library exemplify-extension

PhpSpec extension that adds exemplify command to generate examples in specs

image

rmiller/exemplify-extension

PhpSpec extension that adds exemplify command to generate examples in specs

  • Sunday, February 19, 2017
  • by mr_r_miller
  • Repository
  • 3 Watchers
  • 6 Stars
  • 19,476 Installations
  • PHP
  • 11 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

ExemplifyExtension

Scrutinizer Code Quality Build Status, (*1)

PhpSpec extension that adds exemplify command to generate examples in specs., (*2)

For example, running:, (*3)

bin/phpspec exemplify RMiller/Badger dig

And choosing the default option of 'instance method', will add the following example to the spec/RMiller/BadgerSpec class:, (*4)

public function it_should_dig()
{
    $this->dig();
}

This can then be modified to describe the behaviour for the method., (*5)

Installation

Requires:, (*6)

  • PhpSpec 3.0+
  • PHP 5.6+

To use 'named constructor' examples , you need to use phpspec >2.1. Otherwise the examples will be created but will not run., (*7)

Require the extension:, (*8)

$ composer require --dev rmiller/exemplify-extension:^0.5

Configuration

Activate the extension by specifying its class in your phpspec.yml:, (*9)

# phpspec.yml
extensions:
    RMiller\BehatSpec\Extension\ExemplifyExtension\ExemplifyExtension: ~

Method Types

Three different method types are supported, on running the command you will be asked which type of method is being described. These are:, (*10)

  • Instance Method (e.g. $this->dig())
  • Static Method (e.g. $this::dig())
  • Named Constructor

The names constructor option is for static methods used to instantiate and return an instance of the class. It is essentially another name for a factory method. This is listed separately as the example created is different., (*11)

For example, running:, (*12)

bin/phpspec exemplify RMiller/Badger withName

And choosing the option of 'named constructor', will add the following to the spec/RMiller/BadgerSpec class:, (*13)

public function it_should_be_constructed_through_with_name()
{
    $this->beConstructedThrough('withName');
}

Other Potentially Useful Extensions

  • For further laziness PhpSpecRunExtension will execute the phpspec run command after the describe and exemplify commands, saving a few keystrokes., (*14)

  • This extension and PhpSpecRun are also part of BehatSpec which provides integration between Behat and PhpSpec. This includes running the exemplify command automatically for missing methods encountered when running Behat features., (*15)

The Versions

19/02 2017

dev-master

9999999-dev https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd phpspec

24/01 2017

0.5.0

0.5.0.0 https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd phpspec

24/01 2017

0.4.0

0.4.0.0 https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd phpspec

24/01 2017

0.4.1

0.4.1.0 https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd phpspec

29/09 2016

dev-update-to-phpspec3

dev-update-to-phpspec3 https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd phpspec

21/09 2016

dev-update-to-question-helper

dev-update-to-question-helper https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd phpspec

12/11 2014

0.2.0

0.2.0.0 https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd phpspec

04/11 2014

0.1.0

0.1.0.0 https://github.com/richardmiller/ExemplifyExtension

PhpSpec extension that adds exemplify command to generate examples in specs

  Sources   Download

MIT

The Requires

 

bdd phpspec