Skip to content

Commit

Permalink
Merge pull request phpspec#2 from norzechowicz/interactive
Browse files Browse the repository at this point in the history
Fixed interactive call
  • Loading branch information
jakzal committed Nov 2, 2013
2 parents 2d6f94e + a8e0c7e commit 7fccbbf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
8 changes: 5 additions & 3 deletions features/bootstrap/Console/ApplicationTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public function __construct(Application $application)
*/
public function run($input, array $options = array())
{
$this->input = new StringInput($input);
if (isset($options['interactive'])) {
$this->input->setInteractive($options['interactive']);
if (isset($options['interactive']) && $options['interactive']) {
$this->input = new InteractiveStringInput($input);
} else {
$this->input = new StringInput($input);
$this->input->setInteractive(false);
}

$this->output = new StreamOutput(fopen('php://memory', 'w', false));
Expand Down
12 changes: 12 additions & 0 deletions features/bootstrap/Console/InteractiveStringInput.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

use Symfony\Component\Console\Input\StringInput;

class InteractiveStringInput extends StringInput
{
public function setInteractive($interactive)
{
//this function is disabled to prevent setting non interactive mode on string input after posix_isatty return
//false
}
}
4 changes: 1 addition & 3 deletions features/bootstrap/PhpSpecContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ public function iRunPhpspec()
*/
public function iRunPhpspecAndAnswerToTheFirstQuestion($answer)
{
// @todo this step is now broken, since --no-interaction has been fixed in phpspec...

$this->applicationTester = $this->createApplicationTester();
$this->applicationTester->putToInputStream(sprintf("%s\n", $answer));
$this->applicationTester->run('run --no-interaction');
$this->applicationTester->run('run', array('interactive' => true));
}

/**
Expand Down
1 change: 0 additions & 1 deletion features/describing_a_class.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Feature: Describing a class
When I run phpspec
Then I should see "class Scenario2\Bundle\DemoBundle\Model\User does not exist"

@disabled
Scenario: Generating a class
Given I described the "Scenario3/Bundle/DemoBundle/Model/User"
When I run phpspec and answer "y" to the first question
Expand Down
1 change: 0 additions & 1 deletion features/describing_a_controller.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Feature: Describing a controller
"""

@disabled
Scenario: Generating a controller
Given I described the "Scenario4/Bundle/DemoBundle/Controller/UserController"
When I run phpspec and answer "y" to the first question
Expand Down

0 comments on commit 7fccbbf

Please sign in to comment.