All Projects → karriereat → Phpspec Matchers

karriereat / Phpspec Matchers

Licence: other
Collection of additional matchers for phpspec

Projects that are alternatives of or similar to Phpspec Matchers

gomatch
Library created for testing JSON against patterns.
Stars: ✭ 41 (+28.13%)
Mutual labels:  tdd, bdd
Jgiven
Behavior-Driven Development in plain Java
Stars: ✭ 319 (+896.88%)
Mutual labels:  tdd, bdd
Everydayrails Rspec 2017
Sample source for the 2017 edition of Everyday Rails Testing with RSpec.
Stars: ✭ 280 (+775%)
Mutual labels:  tdd, bdd
TestBox
TestBox is a next generation testing framework for ColdFusion (CFML) that is based on BDD (Behavior Driven Development) for providing a clean obvious syntax for writing tests. It also includes MockBox, our mocking and stubbing framework.
Stars: ✭ 54 (+68.75%)
Mutual labels:  tdd, bdd
Ut
UT: C++20 μ(micro)/Unit Testing Framework
Stars: ✭ 507 (+1484.38%)
Mutual labels:  tdd, bdd
bdd-for-c
A simple BDD library for the C language
Stars: ✭ 90 (+181.25%)
Mutual labels:  tdd, bdd
Lest
A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)
Stars: ✭ 316 (+887.5%)
Mutual labels:  tdd, bdd
mocha-cakes-2
A BDD plugin for Mocha testing framework
Stars: ✭ 44 (+37.5%)
Mutual labels:  tdd, bdd
Mocha
☕️ simple, flexible, fun javascript test framework for node.js & the browser
Stars: ✭ 20,986 (+65481.25%)
Mutual labels:  tdd, bdd
Shellspec
A full-featured BDD unit testing framework for bash, ksh, zsh, dash and all POSIX shells
Stars: ✭ 375 (+1071.88%)
Mutual labels:  tdd, bdd
cucumber
Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
Stars: ✭ 322 (+906.25%)
Mutual labels:  tdd, bdd
Aruba
Test command-line applications with Cucumber-Ruby, RSpec or Minitest. The most up to date documentation can be found on Cucumber.Pro (https://app.cucumber.pro/projects/aruba)
Stars: ✭ 900 (+2712.5%)
Mutual labels:  tdd, bdd
showroom
Universal development and automated test environment for web components
Stars: ✭ 89 (+178.13%)
Mutual labels:  tdd, bdd
respect
RSpec inspired test framework for Reason/OCaml/Bucklescript.
Stars: ✭ 28 (-12.5%)
Mutual labels:  tdd, bdd
apple-mango
Python BDD Pattern
Stars: ✭ 18 (-43.75%)
Mutual labels:  tdd, bdd
List Of Testing Tools And Frameworks For .net
✅ List of Automated Testing (TDD/BDD/ATDD/SBE) Tools and Frameworks for .NET
Stars: ✭ 303 (+846.88%)
Mutual labels:  tdd, bdd
bdd-for-all
Flexible and easy to use library to enable your behavorial driven development (BDD) teams to easily collaborate while promoting automation, transparency and reporting.
Stars: ✭ 42 (+31.25%)
Mutual labels:  tdd, bdd
ginkgo4j
A Java BDD Testing Framework (based on RSpec and Ginkgo)
Stars: ✭ 25 (-21.87%)
Mutual labels:  tdd, bdd
Baretest
An extremely fast and simple JavaScript test runner.
Stars: ✭ 364 (+1037.5%)
Mutual labels:  tdd, bdd
Jasmine Matchers
Write Beautiful Specs with Custom Matchers for Jest and Jasmine
Stars: ✭ 552 (+1625%)
Mutual labels:  tdd, bdd

    Build Status codecov StyleCI

Collection of phpspec Matchers

This package contains a collection of additional phpspec matchers.

Installation

You can install the package via composer

composer require karriere/phpspec-matchers

To be able to use the matchers you need to add the following definition to your phpspec.yml

extensions:
    Karriere\PhpSpecMatchers\Extension: ~

Matcher Usage

All custom matchers in this package implement the positive and the negative case. For example you can use:

$this->method()->shouldBeAnyOf(1, 2, 3);

and also

$this->method()->shouldNotBeAnyOf(1, 2, 3);

Matchers

General Matchers

Json Matchers

General Matchers

beAnyOf

This matcher allows to check the return value against a set of values. Assume you have some sort of random mechanism to get an integer between 2 and 4. The you can use the shouldBeAnyOf matcher:

$this->method()->shouldBeAnyOf(2, 3, 4);

beSomeOf

This matcher allows to check if the returned array values are contained in a set of values.

// $this->method() may return [1, 2, 3]
$this->method()->shouldBeSomeOf(1, 2, 3, 4, 5);

rangeBetween

This matcher allows to check if the given return value is inside a numeric range.

$this->method()->shouldRangeBetween(2, 4);
$this->method()->shouldRangeBetween(0.1, 0.9);

beEmpty

This matcher allows to check if the given return value is empty. The implementation uses the empty implementation.

$this->method()->shouldBeEmpty();

beNull

This matcher allows to check if the given return value is null. The implementation uses the is_null implementation.

$this->method()->shouldBeNull();

beLessThan

This matcher allows to check if the given return value is less than a specified value.

$this->method()->shouldBeLessThan(10);

beGreaterThan

This matcher allows to check if the given return value is greater than a specified value.

$this->method()->shouldBeGreaterThan(10);

Json Matchers

beJson

This matcher checks if the return value is a valid json string

$this->method()->shouldBeJson();

haveJsonKey

This matcher checks if the returned json string contains a json key.

$this->method()->shouldHaveJsonKey('key');

To match against subkey you can use the dot notation. For example let's assume the following json structure

{
  "key": {
    "subkey": "value"
  }
}

The key for this check is 'key.subkey'

$this->method()->shouldHaveJsonKey('key.subkey');

haveJsonKeyWithValue

This matcher checks if the returned json string contains the json key and the desired value. The dot syntax for subkeys can also be applied.

$this->method()->shouldHaveJsonKeyWithValue('key.subkey', 'value');

License

Apache License 2.0 Please see LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].