Created
October 31, 2012 16:57
-
-
Save havvg/3988287 to your computer and use it in GitHub Desktop.
Symfony2 + Jasmine = JasmineHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends '::base.html.twig' %} | |
{% block title %}Ormigo Client-Side Testing Range{% endblock %} | |
{% block stylesheets %} | |
{% stylesheets | |
filter="?yui_css" | |
output="css/jasmine.css" | |
'../vendor/pivotal/jasmine/lib/jasmine-core/jasmine.css' | |
%} | |
<link rel="stylesheet" href="{{ asset_url }}" /> | |
{% endstylesheets %} | |
{% endblock %} | |
{% block head %} | |
{{ parent() }} | |
{% javascripts | |
filter="?yui_js" | |
output="js/jasmine.js" | |
'../vendor/pivotal/jasmine/lib/jasmine-core/jasmine.js' | |
'../vendor/pivotal/jasmine/lib/jasmine-core/jasmine-html.js' | |
%} | |
<script src="{{ asset_url }}"></script> | |
{% endjavascripts %} | |
{% javascripts | |
filter="?yui_js" | |
output="js/jasmine.js" | |
'../app/Resources/js/jasmine/spec/*.js' | |
%} | |
<script src="{{ asset_url }}"></script> | |
{% endjavascripts %} | |
<script> | |
(function () { | |
var jasmineEnv = jasmine.getEnv(); | |
jasmineEnv.updateInterval = 1000; | |
var trivialReporter = new jasmine.TrivialReporter(); | |
jasmineEnv.addReporter(trivialReporter); | |
jasmineEnv.specFilter = function (spec) { | |
return trivialReporter.specFilter(spec); | |
}; | |
var currentWindowOnload = window.onload; | |
window.onload = function () { | |
if (currentWindowOnload) { | |
currentWindowOnload(); | |
} | |
execJasmine(); | |
}; | |
function execJasmine() { | |
jasmineEnv.execute(); | |
} | |
})(); | |
</script> | |
{% endblock %} | |
{% block container %}{% endblock %} | |
{% block footer %}{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Ormigo\Tests; | |
use Symfony\Component\Templating\EngineInterface; | |
use Symfony\Component\HttpFoundation\Response; | |
class JasmineHandler | |
{ | |
protected $templating; | |
protected $template; | |
public function __construct(EngineInterface $templating, $template = '::jasmine.html.twig') | |
{ | |
$this->templating = $templating; | |
$this->template = $template; | |
} | |
public function testAction() | |
{ | |
return new Response($this->templating->render($this->template)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_jasmine: | |
pattern: '/_jasmine' | |
defaults: { _controller: 'jasmine_handler:testAction' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
jasmine_handler: | |
class: Ormigo\Tests\JasmineHandler | |
arguments: | |
- '@templating' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment