Code Monkey home page Code Monkey logo

Comments (7)

anjalirana avatar anjalirana commented on September 23, 2024

I am facing same problem - any update?

from contexts.

wadjei avatar wadjei commented on September 23, 2024

I ran into this and in the end worked around it by adding a shim to my feature context to translate the string true/false into proper booleans.
It's a bit messy but got the job done...

# FeatureContext.php
...
use Sanpi\Behatch\Context\JsonContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;

...


    /**
     *  @BeforeScenario
     */
    public function getBehatchJsonContext(BeforeScenarioScope $scope)
    {
        $environment = $scope->getEnvironment();

        $this->behatchJsonContext = $environment->getContext('Sanpi\Behatch\Context\JsonContext');
    }

    /**
     * @Then the JSON node :node should be boolean :boolAsString
     */
    public function theJsonNodeShouldBeBooleanFalse($node, $boolAsString)
    {
        if (!$this->behatchJsonContext) {
            PHPUnit_Framework_Assert::markTestSkipped('Behatch JsonContext cannot be used.');
        }

        if ($boolAsString == 'false') {
            $bool = false;
        } elseif ($boolAsString == 'true') {
            $bool = true;
        } else {
            PHPUnit_Framework_Assert::markTestSkipped(
                'Invalid value '.var_export($boolAsString,true).' supplied for boolean comparison.'
            );
        }

        // call the behatch JsonContext with a valid boolean.
        return $this->behatchJsonContext->theJsonNodeShouldBeEqualTo($node, $bool);
    }

And in the scenario, changing

And the JSON node "is_completed" should be equal to "false"

to

And the JSON node "is_completed" should be boolean "false"

from contexts.

wadjei avatar wadjei commented on September 23, 2024

There's actually a pair of open pull requests - #115 and #116 - which would address this

from contexts.

MLKiiwy avatar MLKiiwy commented on September 23, 2024

#116 is better I think

from contexts.

sanpii avatar sanpii commented on September 23, 2024

#116 merged.

from contexts.

MLKiiwy avatar MLKiiwy commented on September 23, 2024

Great and could you create a new release version please ?

from contexts.

sanpii avatar sanpii commented on September 23, 2024

@MLKiiwy travis is red, I try to fix that before release 😃

from contexts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.