Commit 684b9850 by Calen Pennington

Make rake commands to run jasmine tests in browser and via phantomjs

parent 763e4722
[submodule "common/test/phantom-jasmine"]
path = common/test/phantom-jasmine
url = https://github.com/jcarver989/phantom-jasmine.git
......@@ -3,3 +3,5 @@ ruby "1.9.3"
gem 'rake'
gem 'sass', '3.1.15'
gem 'bourbon', '~> 1.3.6'
gem 'colorize'
gem 'launchy'
......@@ -11,6 +11,7 @@
<script src="{% static 'jasmine-latest/jasmine.js' %}"></script>
<script src="{% static 'jasmine-latest/jasmine-html.js' %}"></script>
<script src="{% static 'js/vendor/jasmine-jquery.js' %}"></script>
<script src="{% static 'console-runner.js' %}"></script>
{# source files #}
{% for url in suite.js_files %}
......@@ -19,7 +20,7 @@
{% load compressed %}
{# static files #}
{% compressed_js 'main' %}
{% compressed_js 'js-test-source' %}
{# spec files #}
{% compressed_js 'spec' %}
......@@ -31,6 +32,7 @@
<script>
{% block jasmine %}
var console_reporter = new jasmine.ConsoleReporter();
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
......@@ -38,6 +40,7 @@
var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv.addReporter(trivialReporter);
jasmine.getEnv().addReporter(console_reporter);
jasmineEnv.specFilter = function(spec) {
return trivialReporter.specFilter(spec);
......
Subproject commit a54d435b5556650efbcdb0490e6c7928ac75238a
<!doctype html>
<html>
<head>
<title>Jasmine Spec Runner</title>
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'jasmine-latest/jasmine.css' %}" media="screen">
{# core files #}
<script src="{% static 'jasmine-latest/jasmine.js' %}"></script>
<script src="{% static 'jasmine-latest/jasmine-html.js' %}"></script>
<script src="{% static 'js/vendor/jasmine-jquery.js' %}"></script>
{# source files #}
{% for url in suite.js_files %}
<script src="{{ url }}"></script>
{% endfor %}
{% load compressed %}
{# static files #}
{% compressed_js 'application' %}
{% compressed_js 'module-js' %}
{# spec files #}
{% compressed_js 'spec' %}
</head>
<body>
<h1>Jasmine Spec Runner</h1>
<script>
{% block jasmine %}
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv.addReporter(trivialReporter);
jasmineEnv.specFilter = function(spec) {
return trivialReporter.specFilter(spec);
};
// Additional configuration can be done in this block
{% block jasmine_extra %}{% endblock %}
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
{% endblock %}
</script>
</body>
</html>
require 'rake/clean'
require 'tempfile'
require 'net/http'
require 'launchy'
require 'colorize'
# Build Constants
REPO_ROOT = File.dirname(__FILE__)
......@@ -38,6 +41,32 @@ def django_admin(system, env, command, *args)
return "#{django_admin} #{command} --settings=#{system}.envs.#{env} --pythonpath=. #{args.join(' ')}"
end
def django_for_jasmine(system)
django_pid = fork do
exec(*django_admin(system, 'dev', 'runserver', '12345').split(' '))
end
puts django_pid
jasmine_url = 'http://localhost:12345/_jasmine/'
up = false
until up do
begin
response = Net::HTTP.get_response(URI(jasmine_url))
puts response.code
up = response.code == '200'
rescue => e
puts e.message
ensure
puts('Waiting server to start')
sleep(0.5)
end
end
begin
yield jasmine_url
ensure
Process.kill(:SIGKILL, -Process.getpgid(django_pid))
Process.wait(django_pid)
end
end
task :default => [:test, :pep8, :pylint]
directory REPORT_DIR
......@@ -80,6 +109,23 @@ end
end
end
task :pylint => "pylint_#{system}"
desc "Open jasmine tests in your default browser"
task "browse_jasmine_#{system}" do
django_for_jasmine(system) do |jasmine_url|
Launchy.open(jasmine_url)
puts "Press ENTER to terminate".red
$stdin.gets
end
end
desc "Use phantomjs to run jasmine tests from the console"
task "phantomjs_jasmine_#{system}" do
phantomjs = ENV['PHANTOMJS_PATH'] || 'phantomjs'
django_for_jasmine(system) do |jasmine_url|
sh("#{phantomjs} common/test/phantom-jasmine/lib/run_jasmine_test.coffee #{jasmine_url}")
end
end
end
$failed_tests = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment