Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

add bootstrap option #68

Closed
wants to merge 5 commits into from
Closed

add bootstrap option #68

wants to merge 5 commits into from

Conversation

romulodl
Copy link

Added the bootstrap option (issue #52)

After looking the issue and the tips on the pull request 64. I did quickly this peace of code and added this feature:

  • if you add a file called bootstrap.php to the test folder, it will be automatically loaded;
  • Exceptions will be raised if you pass a invalid, inexistent or not pass any file (only --bootstrap without the /path/to/file.php)

TODO: read the yaml file for a possible bootstrap configuration and load it.

I would like a review from you guys if the way I've done is ok or if I'm breaking any pattern that you could be using.

Thanks
Romulo

@romulodl
Copy link
Author

There are bugs on these code, once I have time I will fix them. I just would like a review to know if I'm following the right path

@romulodl
Copy link
Author

  • Added the --bootstrap=path/to/file.php param
  • If the bootstrap option is set up on phpspec.yml, try to load it
  • if the path is empty, the file doesn't exist or the file isn't a ".php". It will return an InvalidArgumentException

Thanks
Romulo

@sivad77
Copy link

sivad77 commented Apr 17, 2013

Any progress with this pull request?

@@ -188,6 +192,10 @@ public function __construct($version)
$c->extend('console.commands', function($c) {
return new Command\DescribeCommand;
});

$c->extend('console.definitions', function($c) {
return new InputOption('bootstrap=/path/to/file.php', null, InputOption::VALUE_REQUIRED, 'Run a bootstrap file before start');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The construction of the option is wrong. The first argument is the name of the option, it should be something like

new InputOption('bootstrap', null, InputOption::VALUE_REQUIRED, 'Run a bootstrap file before start')

see http://api.symfony.com/2.2/Symfony/Component/Console/Input/InputOption.html#method___construct

@benja-M-1
Copy link
Contributor

Actually this PR duplicates this one #64

parent::doRun($input, $output);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

@romulodl
Copy link
Author

Looking at the code. I think it is better that the bootstrap option should be added to the run command, not directly into the Application class. But then I don't know what should be the behavior when someone runs ./bin/phpspec --bootstrap=file.php and the Application assumes that the run command was called.

@romulodl
Copy link
Author

  • Add the bootstrap to the Run Command.
  • The bootstrap file will only be called when you run ./bin/phpspec run --bootstrap="file.php" and not will be called with ./bin/phpspec --bootstrap="file.php"

@romulodl romulodl closed this Apr 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants