Compare commits
94 Commits
sprockets-
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
f7384d684c | ||
|
1055dc1016 | ||
|
c1e786f3c5 | ||
|
aa1d989a90 | ||
|
30e1ff8e51 | ||
|
9b41a36841 | ||
|
65137186c8 | ||
|
a89682f771 | ||
|
3815a47d07 | ||
|
724541a2cb | ||
|
1c81ea7286 | ||
|
8c6a792960 | ||
|
1aac97ea1f | ||
|
21590a9a19 | ||
|
68683e4b6c | ||
|
181f4e286a | ||
|
d572b0d6fe | ||
|
af20af8524 | ||
|
0064595dea | ||
|
2e2651d11a | ||
|
c96cbd4aac | ||
|
4f11cba073 | ||
|
bad6839760 | ||
|
453f439271 | ||
|
142a0c974b | ||
|
75dce5b66b | ||
|
0d4550524f | ||
|
47b8d10d56 | ||
|
d3c3e7bd7d | ||
|
f51f041b85 | ||
|
8de1bd8cf0 | ||
|
09842c0539 | ||
|
5d43eb2193 | ||
|
ed4590ee44 | ||
|
b7553062bd | ||
|
ed76916205 | ||
|
b9b4648a24 | ||
|
282ed40264 | ||
|
1f56031d8b | ||
|
da59a48025 | ||
|
81f561282a | ||
|
dfe1bece2c | ||
|
7587381e1e | ||
|
df83a61cb5 | ||
|
d5b2239d0f | ||
|
d31f628d91 | ||
|
0adf3a41b6 | ||
|
09f4df94de | ||
|
9dafb83892 | ||
|
9ff0dca191 | ||
|
dd86eb404e | ||
|
ac9a9cf23b | ||
|
e38963ed42 | ||
|
8465590930 | ||
|
4c7a1f860d | ||
|
5743227de6 | ||
|
e03389e938 | ||
|
4e64480c69 | ||
|
7dde9328df | ||
|
84e369d30a | ||
|
352ee417c5 | ||
|
00468fc1b3 | ||
|
297f822da1 | ||
|
1099773484 | ||
|
d038a748ed | ||
|
3b0a11edea | ||
|
f3dd4f2bf8 | ||
|
6ad4bdaec0 | ||
|
e25d89962c | ||
|
b6d94a5d0d | ||
|
ab1994696d | ||
|
5d504570fd | ||
|
a291fd5de3 | ||
|
af14f69a07 | ||
|
3c993001de | ||
|
602eb634d7 | ||
|
9affa65df4 | ||
|
0d4562119f | ||
|
ee3b6e598c | ||
|
4ae9815471 | ||
|
3fe66c66c5 | ||
|
f8db052281 | ||
|
16f867af09 | ||
|
03a381d3cc | ||
|
bd6a1afb92 | ||
|
3911041866 | ||
|
edf5a49f27 | ||
|
a18100bb71 | ||
|
08798ff88d | ||
|
a9b879722b | ||
|
115e2eff8b | ||
|
f57a59d767 | ||
|
4f8e732fa4 | ||
|
9b103807ee |
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,3 +14,6 @@ jhw-test
|
|||||||
.jhw-cache/
|
.jhw-cache/
|
||||||
_site/
|
_site/
|
||||||
jhw.*.html
|
jhw.*.html
|
||||||
|
coverage/
|
||||||
|
tmp/
|
||||||
|
cache dir/
|
||||||
|
23
Gemfile
23
Gemfile
@ -6,14 +6,25 @@ gemspec
|
|||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
gem 'fakefs', :require => nil
|
gem 'fakefs', :require => nil
|
||||||
gem 'guard'
|
gem 'guard'
|
||||||
|
|
||||||
gem 'guard-rspec'
|
gem 'guard-rspec'
|
||||||
gem 'guard-shell'
|
gem 'guard-shell'
|
||||||
gem 'guard-coffeescript'
|
gem 'guard-coffeescript'
|
||||||
gem 'growl'
|
gem 'guard-cucumber'
|
||||||
gem 'rake', '0.8.7'
|
|
||||||
gem 'mocha', '0.9.12'
|
|
||||||
gem 'guard-jasmine-headless-webkit', :git => 'git://github.com/johnbintz/guard-jasmine-headless-webkit.git'
|
|
||||||
gem 'facter'
|
|
||||||
|
|
||||||
gem 'jquery-rails'
|
require 'rbconfig'
|
||||||
|
case RbConfig::CONFIG['host_os']
|
||||||
|
when /darwin/
|
||||||
|
when /linux/
|
||||||
|
gem 'libnotify'
|
||||||
|
end
|
||||||
|
|
||||||
|
gem 'mocha'
|
||||||
|
|
||||||
|
gem 'cucumber'
|
||||||
|
|
||||||
|
gem 'jquery-rails', '~> 1.0.0'
|
||||||
gem 'ejs'
|
gem 'ejs'
|
||||||
|
|
||||||
|
gem 'guard-jasmine-headless-webkit', :git => 'git://github.com/johnbintz/guard-jasmine-headless-webkit.git'
|
||||||
|
|
||||||
|
@ -22,13 +22,18 @@ guard 'rspec', :version => 2, :all_on_start => false do
|
|||||||
watch('spec/spec_helper.rb') { "spec" }
|
watch('spec/spec_helper.rb') { "spec" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guard 'cucumber', :cli => '-r features --format pretty' do
|
||||||
|
watch(%r{^features/.+\.feature$})
|
||||||
|
watch(%r{^features/support/.+$}) { 'features' }
|
||||||
|
watch(%r{^features/steps/(.+)_steps\.rb$}) { 'features' }
|
||||||
|
end
|
||||||
|
|
||||||
guard 'jasmine-headless-webkit', :all_on_start => false do
|
guard 'jasmine-headless-webkit', :all_on_start => false do
|
||||||
watch(%r{^spec/javascripts/.+_spec\.coffee})
|
watch(%r{^spec/javascripts/.+_spec\.coffee})
|
||||||
watch(%r{^jasmine/(.+)\.coffee$}) { |m| "spec/javascripts/#{m[1]}_spec.coffee" }
|
watch(%r{^jasmine/(.+)\.coffee$}) { |m| "spec/javascripts/#{m[1]}_spec.coffee" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile
|
def compile
|
||||||
#system %{cd ext/jasmine-webkit-specrunner && ruby test.rb && ruby extconf.rb}
|
|
||||||
system %{cd ext/jasmine-webkit-specrunner && ruby extconf.rb}
|
system %{cd ext/jasmine-webkit-specrunner && ruby extconf.rb}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
15
README.md
15
README.md
@ -1,3 +1,5 @@
|
|||||||
|
_This project is dead. You should use [Karma](http://karma-runner.github.io/) instead. I do._
|
||||||
|
|
||||||
# Jasmine Headless WebKit runner
|
# Jasmine Headless WebKit runner
|
||||||
|
|
||||||
Run your specs at sonic boom speed! No pesky reload button or page rendering slowdowns!
|
Run your specs at sonic boom speed! No pesky reload button or page rendering slowdowns!
|
||||||
@ -5,6 +7,19 @@ Run your specs at sonic boom speed! No pesky reload button or page rendering slo
|
|||||||
http://johnbintz.github.com/jasmine-headless-webkit/ has the most up-to-date information on using
|
http://johnbintz.github.com/jasmine-headless-webkit/ has the most up-to-date information on using
|
||||||
this project. You can see the source of that site on the gh-pages branch.
|
this project. You can see the source of that site on the gh-pages branch.
|
||||||
|
|
||||||
|
## For those who want to hack on the project...
|
||||||
|
|
||||||
|
The best way to get everything running that you need for development and testing is
|
||||||
|
to use Guard:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
bundle install
|
||||||
|
bundle exec guard
|
||||||
|
... build Qt runner ...
|
||||||
|
... compile CoffeeScript to JS ...
|
||||||
|
... run RSpec and JHW ...
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
* Copyright (c) 2011 John Bintz
|
* Copyright (c) 2011 John Bintz
|
||||||
|
22
Rakefile
22
Rakefile
@ -14,7 +14,7 @@ require 'jasmine/headless/task'
|
|||||||
|
|
||||||
Jasmine::Headless::Task.new
|
Jasmine::Headless::Task.new
|
||||||
|
|
||||||
PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3-rc1}
|
PLATFORMS = %w{1.9.2 1.9.3}
|
||||||
|
|
||||||
def rvm_bundle(command = '')
|
def rvm_bundle(command = '')
|
||||||
Bundler.with_clean_env do
|
Bundler.with_clean_env do
|
||||||
@ -30,6 +30,7 @@ namespace :spec do
|
|||||||
task :platforms do
|
task :platforms do
|
||||||
rvm_bundle
|
rvm_bundle
|
||||||
rvm_bundle "exec rspec spec"
|
rvm_bundle "exec rspec spec"
|
||||||
|
rvm_bundle "exec cucumber"
|
||||||
raise SpecError.new if $?.exitstatus != 0
|
raise SpecError.new if $?.exitstatus != 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -43,3 +44,22 @@ task :build_runner do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Generate vendored JS"
|
||||||
|
task :generate_js do
|
||||||
|
require 'sprockets'
|
||||||
|
|
||||||
|
source = 'vendor/assets/coffeescripts'
|
||||||
|
target = 'vendor/assets/javascripts'
|
||||||
|
|
||||||
|
env = Sprockets::Environment.new { |s| s.append_path 'vendor/assets/coffeescripts' }
|
||||||
|
|
||||||
|
Dir[File.join(File.expand_path(source), '*.coffee')].each do |file|
|
||||||
|
file_target = file.gsub(source, target).gsub('.coffee', '.js')
|
||||||
|
puts "#{file} => #{file_target}"
|
||||||
|
|
||||||
|
File.open(file_target, 'wb') do |fh|
|
||||||
|
fh.print env.find_asset(File.expand_path(file)).to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ require 'rubygems'
|
|||||||
$: << File.expand_path('../../lib', __FILE__)
|
$: << File.expand_path('../../lib', __FILE__)
|
||||||
|
|
||||||
require 'jasmine-headless-webkit'
|
require 'jasmine-headless-webkit'
|
||||||
|
require 'coffee-script'
|
||||||
|
|
||||||
Jasmine::Headless::CommandLine.run!
|
Jasmine::Headless::CommandLine.run!
|
||||||
|
|
||||||
|
2
config/cucumber.yml
Normal file
2
config/cucumber.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
default: -r features
|
||||||
|
|
@ -11,6 +11,5 @@ void Page::javaScriptConsoleMessage(const QString & message, int lineNumber, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Page::javaScriptAlert(QWebFrame *, const QString &) {}
|
void Page::javaScriptAlert(QWebFrame *, const QString &) {}
|
||||||
bool Page::javaScriptConfirm(QWebFrame *, const QString &) {
|
bool Page::javaScriptConfirm(QWebFrame *, const QString &) { return false; }
|
||||||
return false;
|
bool Page::javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *) { return false; }
|
||||||
}
|
|
||||||
|
@ -12,6 +12,7 @@ class Page: public QWebPage {
|
|||||||
void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
|
void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
|
||||||
void javaScriptAlert(QWebFrame *, const QString &);
|
void javaScriptAlert(QWebFrame *, const QString &);
|
||||||
bool javaScriptConfirm(QWebFrame *, const QString &);
|
bool javaScriptConfirm(QWebFrame *, const QString &);
|
||||||
|
bool javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *);
|
||||||
signals:
|
signals:
|
||||||
void handleError(const QString & message, int lineNumber, const QString & sourceID);
|
void handleError(const QString & message, int lineNumber, const QString & sourceID);
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,7 @@ Runner::Runner() : QObject()
|
|||||||
, usedConsole(false)
|
, usedConsole(false)
|
||||||
, isFinished(false)
|
, isFinished(false)
|
||||||
, useColors(false)
|
, useColors(false)
|
||||||
|
, quiet(false)
|
||||||
{
|
{
|
||||||
page.settings()->enablePersistentStorage();
|
page.settings()->enablePersistentStorage();
|
||||||
ticker.setInterval(TIMER_TICK);
|
ticker.setInterval(TIMER_TICK);
|
||||||
@ -62,17 +63,17 @@ void Runner::handleError(const QString &message, int lineNumber, const QString &
|
|||||||
|
|
||||||
void Runner::loadSpec()
|
void Runner::loadSpec()
|
||||||
{
|
{
|
||||||
if (reportFileName.isEmpty()) {
|
QVectorIterator<QString> iterator(reportFiles);
|
||||||
outputFile = 0;
|
|
||||||
ts = 0;
|
|
||||||
} else {
|
|
||||||
outputFile = new QFile(reportFileName);
|
|
||||||
outputFile->open(QIODevice::WriteOnly);
|
|
||||||
|
|
||||||
ts = new QTextStream(outputFile);
|
while (iterator.hasNext()) {
|
||||||
|
QFile *outputFile = new QFile(iterator.next());
|
||||||
|
outputFile->open(QIODevice::WriteOnly);
|
||||||
|
outputFiles.enqueue(outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
page.mainFrame()->load(runnerFiles.dequeue());
|
QString runnerFile = runnerFiles.dequeue();
|
||||||
|
|
||||||
|
page.mainFrame()->load(runnerFile);
|
||||||
ticker.start();
|
ticker.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +105,8 @@ void Runner::hasSpecFailure() {
|
|||||||
_hasSpecFailure = true;
|
_hasSpecFailure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner::reportFile(const QString &file) {
|
void Runner::setReportFiles(QStack<QString> &files) {
|
||||||
reportFileName = file;
|
reportFiles = files;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner::timerPause() {
|
void Runner::timerPause() {
|
||||||
@ -120,6 +121,22 @@ void Runner::ping() {
|
|||||||
runs = 0;
|
runs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Runner::setSeed(QString s) {
|
||||||
|
seed = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Runner::setQuiet(bool q) {
|
||||||
|
quiet = q;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Runner::getSeed() {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Runner::isQuiet() {
|
||||||
|
return quiet;
|
||||||
|
}
|
||||||
|
|
||||||
void Runner::print(const QString &fh, const QString &content) {
|
void Runner::print(const QString &fh, const QString &content) {
|
||||||
if (fh == "stdout") {
|
if (fh == "stdout") {
|
||||||
std::cout << qPrintable(content);
|
std::cout << qPrintable(content);
|
||||||
@ -131,14 +148,18 @@ void Runner::print(const QString &fh, const QString &content) {
|
|||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fh == "report" && outputFile) {
|
if (fh.contains("report")) {
|
||||||
*ts << qPrintable(content);
|
int index = (int)fh.split(":").last().toUInt();
|
||||||
ts->flush();
|
|
||||||
|
QTextStream ts(outputFiles.at(index));
|
||||||
|
ts << qPrintable(content);
|
||||||
|
ts.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner::finishSuite() {
|
void Runner::finishSuite() {
|
||||||
isFinished = true;
|
isFinished = true;
|
||||||
|
runs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner::timerEvent() {
|
void Runner::timerEvent() {
|
||||||
@ -147,9 +168,9 @@ void Runner::timerEvent() {
|
|||||||
if (hasErrors && runs > 2)
|
if (hasErrors && runs > 2)
|
||||||
QApplication::instance()->exit(1);
|
QApplication::instance()->exit(1);
|
||||||
|
|
||||||
if (isFinished) {
|
if (isFinished && runs > 2) {
|
||||||
if (outputFile) {
|
while (!outputFiles.isEmpty()) {
|
||||||
outputFile->close();
|
outputFiles.dequeue()->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include "Page.h"
|
#include "Page.h"
|
||||||
|
|
||||||
@ -20,7 +22,10 @@ class Runner: public QObject {
|
|||||||
|
|
||||||
Runner();
|
Runner();
|
||||||
void setColors(bool colors);
|
void setColors(bool colors);
|
||||||
void reportFile(const QString &file);
|
void setReportFiles(QStack<QString> &files);
|
||||||
|
void setSeed(QString s);
|
||||||
|
void setQuiet(bool q);
|
||||||
|
|
||||||
void addFile(const QString &spec);
|
void addFile(const QString &spec);
|
||||||
void go();
|
void go();
|
||||||
|
|
||||||
@ -30,6 +35,10 @@ class Runner: public QObject {
|
|||||||
void hasUsedConsole();
|
void hasUsedConsole();
|
||||||
void hasError();
|
void hasError();
|
||||||
void hasSpecFailure();
|
void hasSpecFailure();
|
||||||
|
|
||||||
|
bool isQuiet();
|
||||||
|
QString getSeed();
|
||||||
|
|
||||||
void print(const QString &fh, const QString &content);
|
void print(const QString &fh, const QString &content);
|
||||||
void finishSuite();
|
void finishSuite();
|
||||||
void ping();
|
void ping();
|
||||||
@ -49,15 +58,16 @@ class Runner: public QObject {
|
|||||||
bool usedConsole;
|
bool usedConsole;
|
||||||
bool isFinished;
|
bool isFinished;
|
||||||
bool useColors;
|
bool useColors;
|
||||||
|
bool quiet;
|
||||||
|
|
||||||
|
QString seed;
|
||||||
|
|
||||||
QQueue<QString> runnerFiles;
|
QQueue<QString> runnerFiles;
|
||||||
|
QStack<QString> reportFiles;
|
||||||
QString reportFileName;
|
|
||||||
|
|
||||||
void loadSpec();
|
void loadSpec();
|
||||||
|
|
||||||
QFile *outputFile;
|
QQueue<QFile *> outputFiles;
|
||||||
QTextStream *ts;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
QMAKE_INFO_PLIST = Info.plist
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
QMAKESPEC = macx-g++
|
|
||||||
QT += network webkit
|
QT += network webkit
|
||||||
|
|
||||||
SOURCES = Page.cpp Runner.cpp
|
SOURCES = Page.cpp Runner.cpp
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
######################################################################
|
|
||||||
# Automatically generated by qmake (2.01a) Tue Aug 2 10:37:48 2011
|
|
||||||
######################################################################
|
|
||||||
|
|
||||||
TEMPLATE = app
|
|
||||||
TARGET =
|
|
||||||
DEPENDPATH += . HeadlessSpecRunner Test
|
|
||||||
INCLUDEPATH += . HeadlessSpecRunner Test
|
|
||||||
|
|
||||||
# Input
|
|
||||||
HEADERS += HeadlessSpecRunner/ConsoleOutput.h \
|
|
||||||
HeadlessSpecRunner/Page.h \
|
|
||||||
HeadlessSpecRunner/Runner.h \
|
|
||||||
Test/Page_test.h
|
|
||||||
SOURCES += specrunner.cpp \
|
|
||||||
HeadlessSpecRunner/ConsoleOutput.cpp \
|
|
||||||
HeadlessSpecRunner/Page.cpp \
|
|
||||||
HeadlessSpecRunner/Runner.cpp \
|
|
||||||
Test/Page_test.cpp
|
|
@ -23,40 +23,54 @@
|
|||||||
|
|
||||||
#include "Runner.h"
|
#include "Runner.h"
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
|
||||||
#error Use Qt 4.7 or later version
|
#error Use Qt 4.7 or later version
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
char *reporter = NULL;
|
bool showColors = false;
|
||||||
char showColors = false;
|
bool isQuiet = false;
|
||||||
|
QString seed;
|
||||||
|
QStack<QString> reporterFiles;
|
||||||
|
|
||||||
int c, index;
|
int c, index;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "cr:")) != -1) {
|
while ((c = getopt(argc, argv, "cr:s:q")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
showColors = true;
|
showColors = true;
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
isQuiet = true;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
reporter = optarg;
|
reporterFiles.push(QString(optarg));
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
seed = QString(optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind == argc) {
|
if (optind == argc) {
|
||||||
std::cerr << "Run Jasmine's SpecRunner headlessly" << std::endl << std::endl;
|
std::cerr << "Run Jasmine's SpecRunner headlessly" << std::endl << std::endl;
|
||||||
std::cerr << " specrunner [-c] [-r <report file>] specrunner.html ..." << std::endl;
|
std::cerr << " specrunner [-c] [-s seed] [-r report file ...] specrunner.html ..." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
app.setApplicationName("jasmine-headless-webkit");
|
app.setApplicationName("jasmine-headless-webkit");
|
||||||
Runner runner;
|
Runner runner;
|
||||||
runner.setColors(showColors);
|
|
||||||
|
|
||||||
runner.reportFile(reporter);
|
runner.setColors(showColors);
|
||||||
|
runner.setQuiet(isQuiet);
|
||||||
|
runner.setReportFiles(reporterFiles);
|
||||||
|
runner.setSeed(seed);
|
||||||
|
|
||||||
for (index = optind; index < argc; index++) {
|
for (index = optind; index < argc; index++) {
|
||||||
runner.addFile(QString::fromLocal8Bit(argv[index]));
|
runner.addFile(QString::fromLocal8Bit(argv[index]));
|
||||||
|
7
features/bin/failure.feature
Normal file
7
features/bin/failure.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - Failure
|
||||||
|
Scenario: Run a failing test
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 1
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage
|
||||||
|
|
7
features/bin/files.feature
Normal file
7
features/bin/files.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - Files
|
||||||
|
Scenario: List the files a test suite will use
|
||||||
|
Given I have a test suite
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml -l`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the output should include "spec/jasmine/success/success.js"
|
||||||
|
And the output should include "spec/jasmine/success/success_spec.js"
|
18
features/bin/filtered_run/both_runs.feature
Normal file
18
features/bin/filtered_run/both_runs.feature
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
Feature: Bin - Filtered Run - Both Runs
|
||||||
|
Background:
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
|
||||||
|
Scenario: Run one and fail
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml -f File:spec/report.txt ./spec/jasmine/filtered_failure/failure_spec.js`
|
||||||
|
Then the exit status should be 1
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage
|
||||||
|
|
||||||
|
Scenario: Run both and succeed
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success/success_one_spec.js`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 2 total, 0 failures, no console usage
|
||||||
|
|
||||||
|
Scenario: Run both with console.log
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success_with_console/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success_with_console/success_one_spec.js`
|
||||||
|
Then the exit status should be 2
|
||||||
|
And the report file "spec/report.txt" should have 2 total, 0 failures, yes console usage
|
14
features/bin/filtered_run/no_full_run.feature
Normal file
14
features/bin/filtered_run/no_full_run.feature
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Feature: Bin - No Full Run
|
||||||
|
Background:
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
|
||||||
|
Scenario: Only run the filtered run
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt --no-full-run ./spec/jasmine/filtered_success/success_one_spec.js`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failure, no console usage
|
||||||
|
|
||||||
|
Scenario: Use a file outside of the normal test run
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success/success_other_file.js`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failure, no console usage
|
||||||
|
|
7
features/bin/help.feature
Normal file
7
features/bin/help.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - Help
|
||||||
|
Scenario: Display the Help
|
||||||
|
Given I have a test suite
|
||||||
|
When I run `bin/jasmine-headless-webkit -h`
|
||||||
|
Then I should get help output
|
||||||
|
And the exit status should be 0
|
||||||
|
|
8
features/bin/quiet_messages.feature
Normal file
8
features/bin/quiet_messages.feature
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Feature: Bin - Quiet Messages
|
||||||
|
Scenario: Run a test that would cause a lot of messages to be displayed and silence them all
|
||||||
|
Given I have a test suite
|
||||||
|
When I run `bin/jasmine-headless-webkit -q -j spec/jasmine/noisy/noisy.yml`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the output should not include "[Skipping File]"
|
||||||
|
And the output should not include "You should mock"
|
||||||
|
|
8
features/bin/runner_out.feature
Normal file
8
features/bin/runner_out.feature
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Feature: Bin - Runner Out
|
||||||
|
Scenario: Write out the runner to a specified file
|
||||||
|
Given I have a test suite
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --runner-out spec/runner.html`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the file "spec/runner.html" should contain a JHW runner
|
||||||
|
When I delete the file "spec/runner.html"
|
||||||
|
|
7
features/bin/spec_files_with_same_basename.feature
Normal file
7
features/bin/spec_files_with_same_basename.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - Two spec files with same basename
|
||||||
|
Scenario: Run both files
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/two_spec_files_same_basename/jasmine.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 2 total, 0 failures, no console usage
|
||||||
|
|
20
features/bin/success.feature
Normal file
20
features/bin/success.feature
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Feature: Bin - Success
|
||||||
|
Scenario: Run a successful test with long format definition
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit --seed 1234 -j spec/jasmine/success/success.yml --format File --out spec/report.txt`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
|
||||||
|
And the report file "spec/report.txt" should have seed 1234
|
||||||
|
|
||||||
|
Scenario: Run a successful test with legacy file reporting
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --report spec/report.txt`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
|
||||||
|
|
||||||
|
Scenario: Run a successful test with shortened format definition
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
|
||||||
|
|
5
features/bin/success_with_js_error.feature
Normal file
5
features/bin/success_with_js_error.feature
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Feature: Bin - Success with JS Error
|
||||||
|
Scenario: Succeed
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 1
|
7
features/bin/tries_to_leave_page.feature
Normal file
7
features/bin/tries_to_leave_page.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - Try to Leave Page
|
||||||
|
Scenario: Fail on trying to leave the page
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/leave_page/leave_page.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 1
|
||||||
|
And the report file "spec/report.txt" should exist
|
||||||
|
|
7
features/bin/try_to_click_a_button.feature
Normal file
7
features/bin/try_to_click_a_button.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - Try to Click A Button
|
||||||
|
Scenario: Don't leave page when clicking a button
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/click_button/click_button.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 0 total, 0 failures, no console usage
|
||||||
|
|
11
features/bin/two_files_from_src_files.feature
Normal file
11
features/bin/two_files_from_src_files.feature
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Feature: Two files from source files
|
||||||
|
Scenario: Files are ordered directly
|
||||||
|
Given I have a test suite
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/two_files_from_src_files/jasmine.yml -l`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the following files should be loaded in order:
|
||||||
|
| vendor/vendor-file.js |
|
||||||
|
| vendor/vendor.js |
|
||||||
|
| app/app-file.js |
|
||||||
|
| app/app.js |
|
||||||
|
|
7
features/bin/with_coffeescript_error.feature
Normal file
7
features/bin/with_coffeescript_error.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - With CoffeeScript error
|
||||||
|
Scenario: Fail on CoffeeScript error
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/coffeescript_error/coffeescript_error.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 1
|
||||||
|
And the report file "spec/report.txt" should not exist
|
||||||
|
|
7
features/bin/with_console_log.feature
Normal file
7
features/bin/with_console_log.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Use console.log
|
||||||
|
Scenario: Run a successful test that uses console.log
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 2
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failures, yes console usage
|
||||||
|
|
7
features/bin/with_server.feature
Normal file
7
features/bin/with_server.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - With Server
|
||||||
|
Scenario: Run using an HTTP server
|
||||||
|
Given there is no existing "spec/report.txt" file
|
||||||
|
When I run `bin/jasmine-headless-webkit --use-server -j spec/jasmine/success/success.yml -f File:spec/report.txt`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
|
||||||
|
|
7
features/bin/with_window_prompt.feature
Normal file
7
features/bin/with_window_prompt.feature
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Feature: Bin - With window.prompt()
|
||||||
|
Scenario: Alert the user that window.prompt() needs to be stubbed
|
||||||
|
Given I have a test suite
|
||||||
|
When I run `bin/jasmine-headless-webkit -j spec/jasmine/window_prompt/window_prompt.yml`
|
||||||
|
Then the exit status should be 0
|
||||||
|
And the output should include "You should mock window.prompt"
|
||||||
|
|
24
features/reporters.feature
Normal file
24
features/reporters.feature
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Feature: Reporters
|
||||||
|
In order to allow for multiple types of output
|
||||||
|
I should be able to
|
||||||
|
Manage reporters and decide which ones to use
|
||||||
|
|
||||||
|
Scenario: Use default reporters
|
||||||
|
Given I have the default runner options
|
||||||
|
When I get a runner
|
||||||
|
And I get a template writer
|
||||||
|
Then the template should use the "Console" reporter to "stdout"
|
||||||
|
And the command to run the runner should not include a report file
|
||||||
|
|
||||||
|
Scenario: Use a file reporter
|
||||||
|
Given I have the default runner options
|
||||||
|
And I have the following reporters:
|
||||||
|
| Name | File |
|
||||||
|
| Console | |
|
||||||
|
| File | file |
|
||||||
|
When I get a runner
|
||||||
|
And I get a template writer
|
||||||
|
Then the template should use the "Console" reporter to "stdout"
|
||||||
|
And the template should use the "File" reporter to "report:0"
|
||||||
|
And the command to run the runner should include the report file "file"
|
||||||
|
|
34
features/runner.feature
Normal file
34
features/runner.feature
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
Feature: Using the Runner directly
|
||||||
|
Scenario: Succeed
|
||||||
|
Given I have the following runner options:
|
||||||
|
"""
|
||||||
|
:jasmine_config: spec/jasmine/success/success.yml
|
||||||
|
:reporters:
|
||||||
|
- [ 'File', 'spec/report.txt' ]
|
||||||
|
"""
|
||||||
|
When I get a runner
|
||||||
|
And I run the runner
|
||||||
|
Then the runner should have an exit status of 0
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
|
||||||
|
|
||||||
|
Scenario: JavaScript Error
|
||||||
|
Given I have the following runner options:
|
||||||
|
"""
|
||||||
|
:jasmine_config: spec/jasmine/success_with_error/success_with_error.yml
|
||||||
|
"""
|
||||||
|
When I get a runner
|
||||||
|
And I run the runner
|
||||||
|
Then the runner should have an exit status of 1
|
||||||
|
|
||||||
|
Scenario: Failure
|
||||||
|
Given I have the following runner options:
|
||||||
|
"""
|
||||||
|
:jasmine_config: spec/jasmine/failure/failure.yml
|
||||||
|
:reporters:
|
||||||
|
- [ 'File', 'spec/report.txt' ]
|
||||||
|
"""
|
||||||
|
When I get a runner
|
||||||
|
And I run the runner
|
||||||
|
Then the runner should have an exit status of 1
|
||||||
|
And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage
|
||||||
|
|
2
features/steps/given/i_have_test_suite.rb
Normal file
2
features/steps/given/i_have_test_suite.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Given /^I have a test suite$/ do
|
||||||
|
end
|
4
features/steps/given/no_existing_file.rb
Normal file
4
features/steps/given/no_existing_file.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Given /^there is no existing "([^"]*)" file$/ do |file|
|
||||||
|
FileUtils.rm_rf file
|
||||||
|
end
|
||||||
|
|
4
features/steps/given/options/i_have_defaults.rb
Normal file
4
features/steps/given/options/i_have_defaults.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Given /^I have the default runner options$/ do
|
||||||
|
@options = Jasmine::Headless::Options.new
|
||||||
|
end
|
||||||
|
|
10
features/steps/given/options/i_have_reporters.rb
Normal file
10
features/steps/given/options/i_have_reporters.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Given /^I have the following reporters:$/ do |table|
|
||||||
|
@options[:reporters] = []
|
||||||
|
|
||||||
|
table.hashes.each do |hash|
|
||||||
|
reporter = [ hash['Name'] ]
|
||||||
|
reporter << hash['File'] if !hash['File'].empty?
|
||||||
|
|
||||||
|
@options[:reporters] << reporter
|
||||||
|
end
|
||||||
|
end
|
3
features/steps/given/options/i_have_runner_options.rb
Normal file
3
features/steps/given/options/i_have_runner_options.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Given /^I have the following runner options:$/ do |string|
|
||||||
|
@options = YAML.load(string)
|
||||||
|
end
|
3
features/steps/then/bin/exit_status_should_be.rb
Normal file
3
features/steps/then/bin/exit_status_should_be.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Then /^the exit status should be (\d+)$/ do |exitstatus|
|
||||||
|
$?.exitstatus.should == exitstatus.to_i
|
||||||
|
end
|
4
features/steps/then/bin/file_should_contain_runner.rb
Normal file
4
features/steps/then/bin/file_should_contain_runner.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Then /^the file "([^"]*)" should contain a JHW runner$/ do |file|
|
||||||
|
File.read(file).should include('jasmine.HeadlessReporter')
|
||||||
|
end
|
||||||
|
|
10
features/steps/then/bin/following_files_loaded_in_order.rb
Normal file
10
features/steps/then/bin/following_files_loaded_in_order.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Then /^the following files should be loaded in order:$/ do |table|
|
||||||
|
files = table.raw.flatten
|
||||||
|
|
||||||
|
@output.lines.collect(&:strip).each do |line|
|
||||||
|
files.shift if line[files.first]
|
||||||
|
end
|
||||||
|
|
||||||
|
files.should be_empty
|
||||||
|
end
|
||||||
|
|
4
features/steps/then/bin/i_should_get_help_output.rb
Normal file
4
features/steps/then/bin/i_should_get_help_output.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Then /^I should get help output$/ do
|
||||||
|
@output.should include("Usage:")
|
||||||
|
end
|
||||||
|
|
3
features/steps/then/bin/output_should_include.rb
Normal file
3
features/steps/then/bin/output_should_include.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Then /^the output should include "([^"]*)"$/ do |string|
|
||||||
|
@output.should include(string)
|
||||||
|
end
|
4
features/steps/then/bin/output_should_not_include.rb
Normal file
4
features/steps/then/bin/output_should_not_include.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Then /^the output should not include "([^"]*)"$/ do |string|
|
||||||
|
@output.should_not include(string)
|
||||||
|
end
|
||||||
|
|
4
features/steps/then/reporting/report_does_not_exist.rb
Normal file
4
features/steps/then/reporting/report_does_not_exist.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Then /^the report file "([^"]*)" should not exist$/ do |file|
|
||||||
|
File.file?(file).should be_false
|
||||||
|
end
|
||||||
|
|
3
features/steps/then/reporting/report_should_exist.rb
Normal file
3
features/steps/then/reporting/report_should_exist.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Then /^the report file "([^"]*)" should exist$/ do |file|
|
||||||
|
File.file?(file).should be_true
|
||||||
|
end
|
7
features/steps/then/reporting/report_should_have.rb
Normal file
7
features/steps/then/reporting/report_should_have.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Then /^the report file "(.*)" should have (\d+) total, (\d+) failures?, (no|yes) console usage$/ do |file, total, failures, console_usage|
|
||||||
|
report = Jasmine::Headless::Report.load(file)
|
||||||
|
|
||||||
|
report.total.should == total.to_i
|
||||||
|
report.failed.should == failures.to_i
|
||||||
|
report.has_used_console?.should == (console_usage == 'yes')
|
||||||
|
end
|
4
features/steps/then/reporting/report_should_have_seed.rb
Normal file
4
features/steps/then/reporting/report_should_have_seed.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Then /^the report file "([^"]*)" should have seed (\d+)$/ do |file, seed|
|
||||||
|
report = Jasmine::Headless::Report.load(file)
|
||||||
|
report.seed.should == seed.to_i
|
||||||
|
end
|
3
features/steps/then/runner/it_should_have_exit_status.rb
Normal file
3
features/steps/then/runner/it_should_have_exit_status.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Then /^the runner should have an exit status of (\d+)$/ do |exit_status|
|
||||||
|
@result.should == exit_status.to_i
|
||||||
|
end
|
@ -0,0 +1,4 @@
|
|||||||
|
Then /^the command to run the runner should include the report file "([^"]*)"$/ do |file|
|
||||||
|
@runner.jasmine_command.should include("-r #{file}")
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
Then /^the command to run the runner should not include a report file$/ do
|
||||||
|
@runner.jasmine_command.should_not include('-r')
|
||||||
|
end
|
6
features/steps/then/templates/it_should_use_reporter.rb
Normal file
6
features/steps/then/templates/it_should_use_reporter.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Then /^the template should use the "([^"]*)" reporter to "([^"]*)"$/ do |reporter, target|
|
||||||
|
output = @template_writer.render
|
||||||
|
|
||||||
|
output.should include(%{jasmine.HeadlessReporter.#{reporter}("#{target}")})
|
||||||
|
end
|
||||||
|
|
3
features/steps/when/i_delete_file.rb
Normal file
3
features/steps/when/i_delete_file.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
When /^I delete the file "([^"]*)"$/ do |file|
|
||||||
|
FileUtils.rm_f(file)
|
||||||
|
end
|
4
features/steps/when/i_get_runner.rb
Normal file
4
features/steps/when/i_get_runner.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
When /^I get a runner$/ do
|
||||||
|
@runner = Jasmine::Headless::Runner.new(@options)
|
||||||
|
end
|
||||||
|
|
4
features/steps/when/i_get_template_writer.rb
Normal file
4
features/steps/when/i_get_template_writer.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
When /^I get a template writer$/ do
|
||||||
|
@template_writer = Jasmine::Headless::TemplateWriter.new(@runner)
|
||||||
|
end
|
||||||
|
|
4
features/steps/when/i_run_executable.rb
Normal file
4
features/steps/when/i_run_executable.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
When /^I run `(.*)`$/ do |command|
|
||||||
|
@output = `#{command}`
|
||||||
|
end
|
||||||
|
|
4
features/steps/when/i_run_runner.rb
Normal file
4
features/steps/when/i_run_runner.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
When /^I run the runner$/ do
|
||||||
|
@result = @runner.run
|
||||||
|
end
|
||||||
|
|
7
features/support/env.rb
Normal file
7
features/support/env.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'jasmine-headless-webkit'
|
||||||
|
|
||||||
|
After do
|
||||||
|
FileUtils.rm_f 'spec/report.txt'
|
||||||
|
FileUtils.rm_f 'spec/runner.html'
|
||||||
|
end
|
||||||
|
|
@ -20,9 +20,11 @@ Gem::Specification.new do |s|
|
|||||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
|
|
||||||
s.add_runtime_dependency 'jasmine-core', '~> 1.1'
|
s.add_runtime_dependency 'jasmine-core'
|
||||||
s.add_runtime_dependency 'coffee-script'
|
s.add_runtime_dependency 'coffee-script'
|
||||||
s.add_runtime_dependency 'rainbow'
|
s.add_runtime_dependency 'rainbow'
|
||||||
s.add_runtime_dependency 'multi_json'
|
s.add_runtime_dependency 'multi_json', '>= 1.2.0'
|
||||||
s.add_runtime_dependency 'sprockets', '~> 2'
|
s.add_runtime_dependency 'sprockets'
|
||||||
|
s.add_runtime_dependency 'sprockets-vendor_gems'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,32 +1,61 @@
|
|||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine
|
||||||
autoload :CommandLine, 'jasmine/headless/command_line'
|
module Headless
|
||||||
|
|
||||||
autoload :CoffeeScriptCache, 'jasmine/headless/coffee_script_cache'
|
EXCLUDED_FORMATS = %w{less sass scss erb str}
|
||||||
autoload :SpecFileAnalyzer, 'jasmine/headless/spec_file_analyzer'
|
|
||||||
autoload :CacheableAction, 'jasmine/headless/cacheable_action'
|
|
||||||
autoload :VERSION, 'jasmine/headless/version'
|
|
||||||
autoload :Runner, 'jasmine/headless/runner'
|
|
||||||
autoload :Options, 'jasmine/headless/options'
|
|
||||||
autoload :Task, 'jasmine/headless/task'
|
|
||||||
autoload :FilesList, 'jasmine/headless/files_list'
|
|
||||||
|
|
||||||
autoload :TemplateWriter, 'jasmine/headless/template_writer'
|
autoload :CommandLine, 'jasmine/headless/command_line'
|
||||||
|
|
||||||
autoload :CoffeeTemplate, 'jasmine/headless/coffee_template'
|
autoload :CoffeeScriptCache, 'jasmine/headless/coffee_script_cache'
|
||||||
autoload :JSTemplate, 'jasmine/headless/js_template'
|
autoload :SpecFileAnalyzer, 'jasmine/headless/spec_file_analyzer'
|
||||||
autoload :JSTTemplate, 'jasmine/headless/jst_template'
|
autoload :CacheableAction, 'jasmine/headless/cacheable_action'
|
||||||
autoload :CSSTemplate, 'jasmine/headless/css_template'
|
autoload :VERSION, 'jasmine/headless/version'
|
||||||
|
autoload :Runner, 'jasmine/headless/runner'
|
||||||
|
autoload :Options, 'jasmine/headless/options'
|
||||||
|
autoload :Task, 'jasmine/headless/task'
|
||||||
|
|
||||||
autoload :Report, 'jasmine/headless/report'
|
autoload :FilesList, 'jasmine/headless/files_list'
|
||||||
autoload :ReportMessage, 'jasmine/headless/report_message'
|
autoload :UniqueAssetList, 'jasmine/headless/unique_asset_list'
|
||||||
|
|
||||||
class << self
|
autoload :TemplateWriter, 'jasmine/headless/template_writer'
|
||||||
def root
|
|
||||||
@root ||= Pathname(File.expand_path('../../..', __FILE__))
|
autoload :FileChecker, 'jasmine/headless/file_checker'
|
||||||
|
|
||||||
|
autoload :CoffeeTemplate, 'jasmine/headless/coffee_template'
|
||||||
|
autoload :JSTemplate, 'jasmine/headless/js_template'
|
||||||
|
autoload :JSTTemplate, 'jasmine/headless/jst_template'
|
||||||
|
autoload :CSSTemplate, 'jasmine/headless/css_template'
|
||||||
|
autoload :NilTemplate, 'jasmine/headless/nil_template'
|
||||||
|
|
||||||
|
autoload :Report, 'jasmine/headless/report'
|
||||||
|
autoload :ReportMessage, 'jasmine/headless/report_message'
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def root
|
||||||
|
@root ||= Pathname(File.expand_path('../../..', __FILE__))
|
||||||
|
end
|
||||||
|
|
||||||
|
def warn(message)
|
||||||
|
output.puts message if show_warnings?
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_warnings=(show)
|
||||||
|
@show_warnings = show
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_warnings?
|
||||||
|
@show_warnings = true if @show_warnings.nil?
|
||||||
|
|
||||||
|
@show_warnings
|
||||||
|
end
|
||||||
|
|
||||||
|
def output
|
||||||
|
$stdout
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'jasmine/headless/errors'
|
require 'jasmine/headless/errors'
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
require 'digest/sha1'
|
|
||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine::Headless
|
||||||
class CacheableAction
|
class CacheableAction
|
||||||
class << self
|
class << self
|
||||||
@ -56,7 +54,11 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cache_file
|
def cache_file
|
||||||
@cache_file ||= File.join(self.class.cache_dir, self.class.cache_type, Digest::SHA1.hexdigest(file)) + '.js'
|
@cache_file ||= File.expand_path(relative_cache_file) + '.js'
|
||||||
|
end
|
||||||
|
|
||||||
|
def relative_cache_file
|
||||||
|
File.join(self.class.cache_dir, self.class.cache_type, file.gsub(Dir.pwd + '/', ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fresh?
|
def fresh?
|
||||||
|
@ -3,19 +3,25 @@ require 'rainbow'
|
|||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine::Headless
|
||||||
class CoffeeTemplate < Tilt::Template
|
class CoffeeTemplate < Tilt::Template
|
||||||
|
include Jasmine::Headless::FileChecker
|
||||||
|
|
||||||
self.default_mime_type = 'application/javascript'
|
self.default_mime_type = 'application/javascript'
|
||||||
|
|
||||||
def prepare ; end
|
def prepare ; end
|
||||||
|
|
||||||
def evaluate(scope, locals, &block)
|
def evaluate(scope, locals, &block)
|
||||||
|
if bad_format?(file)
|
||||||
|
alert_bad_format(file)
|
||||||
|
return ''
|
||||||
|
end
|
||||||
begin
|
begin
|
||||||
cache = Jasmine::Headless::CoffeeScriptCache.new(file)
|
cache = Jasmine::Headless::CoffeeScriptCache.new(file)
|
||||||
source = cache.handle
|
source = cache.handle
|
||||||
if cache.cached?
|
if cache.cached?
|
||||||
%{<script from="jhw" type="text/javascript" src="#{cache.cache_file}"></script>
|
%{<script type="text/javascript" src="#{cache.cache_file}"></script>
|
||||||
<script type="text/javascript">window.CSTF['#{File.split(cache.cache_file).last}'] = '#{file}';</script>}
|
<script type="text/javascript">window.CSTF['#{File.split(cache.cache_file).last}'] = '#{file}';</script>}
|
||||||
else
|
else
|
||||||
%{<script from="jhw" type="text/javascript">#{source}</script>}
|
%{<script type="text/javascript">#{source}</script>}
|
||||||
end
|
end
|
||||||
rescue CoffeeScript::CompilationError => ne
|
rescue CoffeeScript::CompilationError => ne
|
||||||
puts "[%s] %s: %s" % [ 'coffeescript'.color(:red), file.color(:yellow), "#{ne.message}".color(:white) ]
|
puts "[%s] %s: %s" % [ 'coffeescript'.color(:red), file.color(:yellow), "#{ne.message}".color(:white) ]
|
||||||
|
@ -2,11 +2,16 @@ require 'tilt/template'
|
|||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine::Headless
|
||||||
class CSSTemplate < Tilt::Template
|
class CSSTemplate < Tilt::Template
|
||||||
|
include Jasmine::Headless::FileChecker
|
||||||
self.default_mime_type = 'text/css'
|
self.default_mime_type = 'text/css'
|
||||||
|
|
||||||
def prepare ; end
|
def prepare ; end
|
||||||
|
|
||||||
def evaluate(scope, locals, &block)
|
def evaluate(scope, locals, &block)
|
||||||
|
if bad_format?(file)
|
||||||
|
alert_bad_format(file)
|
||||||
|
return ''
|
||||||
|
end
|
||||||
file ? %{<link rel="stylesheet" href="#{file}" type="text/css" />} : data
|
file ? %{<link rel="stylesheet" href="#{file}" type="text/css" />} : data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
25
lib/jasmine/headless/file_checker.rb
Normal file
25
lib/jasmine/headless/file_checker.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
module Jasmine::Headless::FileChecker
|
||||||
|
def excluded_formats
|
||||||
|
::Jasmine::Headless::EXCLUDED_FORMATS
|
||||||
|
end
|
||||||
|
|
||||||
|
def bad_format?(file)
|
||||||
|
return if file.nil?
|
||||||
|
|
||||||
|
excluded_formats.any? do |format|
|
||||||
|
file[%r{\.#{format}(\.|$)}]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def alert_bad_format(file)
|
||||||
|
Jasmine::Headless.warn("[%s] %s: %s" % [ 'Skipping File'.color(:red), file.color(:yellow), "unsupported format".color(:white) ])
|
||||||
|
end
|
||||||
|
|
||||||
|
def alert_if_bad_format?(file)
|
||||||
|
if result = bad_format?(file)
|
||||||
|
alert_bad_format(file)
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
@ -4,74 +4,112 @@ require 'multi_json'
|
|||||||
require 'set'
|
require 'set'
|
||||||
require 'sprockets'
|
require 'sprockets'
|
||||||
require 'sprockets/engines'
|
require 'sprockets/engines'
|
||||||
|
require 'sprockets-vendor_gems'
|
||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine::Headless
|
||||||
class FilesList
|
class FilesList
|
||||||
|
include FileChecker
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def vendor_asset_paths
|
def asset_paths
|
||||||
return @vendor_asset_paths if @vendor_asset_paths
|
@asset_paths ||= Sprockets.find_gem_vendor_paths(:for => 'javascripts')
|
||||||
|
|
||||||
require 'rubygems'
|
|
||||||
|
|
||||||
raise StandardError.new("A newer version of Rubygems is required to use vendored assets. Please upgrade.") if !Gem::Specification.respond_to?(:map)
|
|
||||||
|
|
||||||
@vendor_asset_paths = []
|
|
||||||
|
|
||||||
Gem::Specification.map { |spec|
|
|
||||||
path = File.join(spec.gem_dir, 'vendor/assets/javascripts')
|
|
||||||
|
|
||||||
File.directory?(path) ? path : nil
|
|
||||||
}.compact
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset!
|
def reset!
|
||||||
@vendor_asset_paths = nil
|
@asset_paths = nil
|
||||||
|
@registered_engines = {}
|
||||||
|
|
||||||
# register haml-sprockets if it's available...
|
# register haml-sprockets and handlebars_assets if it's available...
|
||||||
%w{haml-sprockets}.each do |library|
|
%w{haml-sprockets handlebars_assets}.each do |library|
|
||||||
begin
|
begin
|
||||||
require library
|
require library
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# ...and unregister ones we don't want/need
|
if ENV['JHW_ENV']
|
||||||
Sprockets.instance_eval do
|
begin
|
||||||
%w{less sass scss erb str}.each do |extension|
|
require 'bundler'
|
||||||
@engines.delete(".#{extension}")
|
|
||||||
end
|
|
||||||
|
|
||||||
register_engine '.coffee', Jasmine::Headless::CoffeeTemplate
|
Bundler.require(ENV['JHW_ENV'].to_sym)
|
||||||
register_engine '.js', Jasmine::Headless::JSTemplate
|
rescue LoadError
|
||||||
register_engine '.css', Jasmine::Headless::CSSTemplate
|
end
|
||||||
register_engine '.jst', Jasmine::Headless::JSTTemplate
|
end
|
||||||
|
|
||||||
|
@sprockets_environment = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def registered_engines
|
||||||
|
@registered_engines ||= {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def register_engine(file_extension, template_class)
|
||||||
|
registered_engines[file_extension] = template_class
|
||||||
|
end
|
||||||
|
|
||||||
|
def register_engines!
|
||||||
|
registered_engines.each do |file_extension, template_class|
|
||||||
|
Sprockets.register_engine file_extension, template_class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_files
|
def default_files
|
||||||
%w{jasmine.js jasmine-html jasmine.css jasmine-extensions intense headless_reporter_result jasmine.HeadlessConsoleReporter jsDump beautify-html}
|
%w{jasmine.js jasmine-html jasmine.css jasmine-extensions
|
||||||
|
intense headless_reporter_result jasmine.HeadlessReporter
|
||||||
|
jasmine.HeadlessReporter.ConsoleBase
|
||||||
|
jsDump beautify-html}
|
||||||
|
end
|
||||||
|
|
||||||
|
def extension_filter
|
||||||
|
extensions = (%w{.js .css} + Sprockets.engine_extensions)
|
||||||
|
|
||||||
|
%r{(#{extensions.join('|')})$}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
PLEASE_WAIT_IM_WORKING_TIME = 2
|
PLEASE_WAIT_IM_WORKING_TIME = 2
|
||||||
|
|
||||||
attr_reader :required_files, :potential_files_to_filter
|
attr_reader :options, :required_files, :potential_files_to_filter
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
@required_files = []
|
Kernel.srand(options[:seed]) if options[:seed]
|
||||||
|
|
||||||
|
@required_files = UniqueAssetList.new
|
||||||
@potential_files_to_filter = []
|
@potential_files_to_filter = []
|
||||||
|
|
||||||
|
register_engines!
|
||||||
|
|
||||||
|
load_initial_assets
|
||||||
|
|
||||||
|
use_config if config?
|
||||||
|
end
|
||||||
|
|
||||||
|
def register_engines!
|
||||||
|
begin
|
||||||
|
require spec_helper
|
||||||
|
rescue LoadError
|
||||||
|
end
|
||||||
|
self.class.register_engines!
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_initial_assets
|
||||||
self.class.default_files.each do |file|
|
self.class.default_files.each do |file|
|
||||||
@required_files << sprockets_environment.find_asset(file, :bundle => false)
|
begin
|
||||||
|
add_path(file)
|
||||||
|
rescue InvalidUniqueAsset => e
|
||||||
|
raise StandardError.new("Not an asset: #{file}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
use_config! if config?
|
(options[:reporters] || []).each do |reporter, identifier, file|
|
||||||
|
add_path("jasmine.HeadlessReporter.#{reporter}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def files
|
def files
|
||||||
required_files.collect { |file| file.to_a.collect { |asset| asset.pathname.to_s } }.flatten.uniq
|
required_files.flatten.collect { |asset| asset.pathname.to_s }.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_files
|
def spec_files
|
||||||
@ -87,11 +125,13 @@ module Jasmine::Headless
|
|||||||
def search_paths
|
def search_paths
|
||||||
return @search_paths if @search_paths
|
return @search_paths if @search_paths
|
||||||
|
|
||||||
@search_paths = [ Jasmine::Core.path ]
|
@search_paths = [ Jasmine::Core.path, Jasmine::Headless.root.join('vendor/assets/javascripts').to_s ]
|
||||||
|
@search_paths += self.class.asset_paths
|
||||||
@search_paths += src_dir.collect { |dir| File.expand_path(dir) }
|
@search_paths += src_dir.collect { |dir| File.expand_path(dir) }
|
||||||
|
@search_paths += asset_paths.collect { |dir| File.expand_path(dir) }
|
||||||
@search_paths += spec_dir.collect { |dir| File.expand_path(dir) }
|
@search_paths += spec_dir.collect { |dir| File.expand_path(dir) }
|
||||||
@search_paths += self.class.vendor_asset_paths
|
|
||||||
|
|
||||||
|
@search_paths.uniq!
|
||||||
@search_paths
|
@search_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,25 +139,33 @@ module Jasmine::Headless
|
|||||||
return @sprockets_environment if @sprockets_environment
|
return @sprockets_environment if @sprockets_environment
|
||||||
|
|
||||||
@sprockets_environment = Sprockets::Environment.new
|
@sprockets_environment = Sprockets::Environment.new
|
||||||
search_paths.each do |path|
|
search_paths.each { |path| @sprockets_environment.append_path(path) }
|
||||||
@sprockets_environment.append_path(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
@sprockets_environment.unregister_postprocessor('application/javascript', Sprockets::SafetyColons)
|
@sprockets_environment.unregister_postprocessor('application/javascript', Sprockets::SafetyColons)
|
||||||
@sprockets_environment
|
|
||||||
end
|
|
||||||
|
|
||||||
def path_searcher
|
# ...and unregister ones we don't want/need
|
||||||
@path_searcher ||= PathSearcher.new(self)
|
@sprockets_environment.instance_eval do
|
||||||
|
EXCLUDED_FORMATS.each do |extension|
|
||||||
|
register_engine ".#{extension}", Jasmine::Headless::NilTemplate
|
||||||
|
end
|
||||||
|
|
||||||
|
register_engine '.coffee', Jasmine::Headless::CoffeeTemplate
|
||||||
|
register_engine '.js', Jasmine::Headless::JSTemplate
|
||||||
|
register_engine '.css', Jasmine::Headless::CSSTemplate
|
||||||
|
register_engine '.jst', Jasmine::Headless::JSTTemplate
|
||||||
|
end
|
||||||
|
|
||||||
|
@sprockets_environment
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_spec_outside_scope?
|
def has_spec_outside_scope?
|
||||||
if is_outside_scope = !spec_filter.empty?
|
if is_outside_scope = !spec_filter.empty?
|
||||||
is_outside_scope = spec_dir.any? do |dir|
|
is_outside_scope = spec_dir.any? do |dir|
|
||||||
spec_file_searches.any? do |search|
|
spec_file_searches.any? do |search|
|
||||||
!spec_files.any? { |file|
|
!spec_files.any? do |file|
|
||||||
File.fnmatch?(File.join(dir, search), file)
|
target = File.join(dir, search)
|
||||||
}
|
File.fnmatch?(target, file) || File.fnmatch?(target.gsub(%{^**/}, ''), file)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -160,19 +208,11 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
|
|
||||||
sprockets_environment.find_asset(file, :bundle => false).body
|
sprockets_environment.find_asset(file, :bundle => false).body
|
||||||
end.flatten.compact.reject(&:empty?)
|
end.compact.reject(&:empty?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_filter
|
def spec_filter
|
||||||
return @spec_filter if @spec_filter
|
@spec_filter ||= (@options[:only] && @options[:only].collect { |path| expanded_dir(path) }.flatten) || []
|
||||||
|
|
||||||
@spec_filter = begin
|
|
||||||
if @options[:only]
|
|
||||||
@options[:only].collect { |path| expanded_dir(path) }.flatten
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SEARCH_ROOTS = {
|
SEARCH_ROOTS = {
|
||||||
@ -182,37 +222,25 @@ module Jasmine::Headless
|
|||||||
'spec_files' => 'spec_dir'
|
'spec_files' => 'spec_dir'
|
||||||
}
|
}
|
||||||
|
|
||||||
def use_config!
|
def use_config
|
||||||
@config = @options[:config].dup
|
@config = @options[:config].dup
|
||||||
@searches = {}
|
@searches = {}
|
||||||
@potential_files_to_filter = []
|
@potential_files_to_filter = []
|
||||||
|
|
||||||
%w{src_files stylesheets helpers spec_files}.each do |type|
|
%w{src_files stylesheets helpers spec_files}.each do |type|
|
||||||
if data = @config[type]
|
if data = @config[type]
|
||||||
dirs = send(SEARCH_ROOTS[type])
|
add_files(@searches[type] = data.flatten, type, send(SEARCH_ROOTS[type]))
|
||||||
|
|
||||||
add_files(@searches[type] = data.flatten, type, dirs)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
filtered_required_files = []
|
|
||||||
|
|
||||||
@required_files.each do |file|
|
|
||||||
if !filtered_required_files.any? { |other_file| other_file.logical_path == file.logical_path }
|
|
||||||
filtered_required_files << file
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@required_files = filtered_required_files
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_files(patterns, type, dirs)
|
def add_files(patterns, type, dirs)
|
||||||
dirs.each do |dir|
|
patterns.each do |pattern|
|
||||||
patterns.each do |search|
|
dirs.collect { |dir| expanded_dir(File.join(dir, pattern)) }.each do |files|
|
||||||
search = File.expand_path(File.join(dir, search))
|
files.sort! { |a, b| Kernel.rand(3) - 1 } if type == 'spec_files'
|
||||||
|
|
||||||
Dir[search].find_all { |file| file[extension_filter] }.each do |path|
|
files.each do |path|
|
||||||
add_path(path, type) if File.file?(path)
|
add_path(path, type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -227,14 +255,21 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
|
|
||||||
def expanded_dir(path)
|
def expanded_dir(path)
|
||||||
Dir[path].collect { |file| File.expand_path(file) }.find_all { |path| File.file?(path) && path[extension_filter] }
|
file_list = Dir.glob(path).sort
|
||||||
|
file_list.find_all { |file|
|
||||||
|
file[extension_filter] && !alert_if_bad_format?(file)
|
||||||
|
}.collect {
|
||||||
|
|file| File.expand_path(file)
|
||||||
|
}.find_all {
|
||||||
|
|path| File.file?(path)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def extension_filter
|
def extension_filter
|
||||||
%r{(#{(%w{.js .css} + Sprockets.engine_extensions).join('|')})$}
|
self.class.extension_filter
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_path(path, type)
|
def add_path(path, type = nil)
|
||||||
asset = sprockets_environment.find_asset(path)
|
asset = sprockets_environment.find_asset(path)
|
||||||
|
|
||||||
@required_files << asset
|
@required_files << asset
|
||||||
@ -244,16 +279,16 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_spec_file?(file)
|
|
||||||
spec_filter.empty? || spec_filter.include?(file)
|
|
||||||
end
|
|
||||||
|
|
||||||
def src_dir
|
def src_dir
|
||||||
config_dir_or_pwd('src_dir')
|
@src_dir ||= config_dir_or_pwd('src_dir') + asset_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_dir
|
def spec_dir
|
||||||
config_dir_or_pwd('spec_dir')
|
@spec_dir ||= config_dir_or_pwd('spec_dir')
|
||||||
|
end
|
||||||
|
|
||||||
|
def asset_paths
|
||||||
|
@asset_paths ||= config_dir('asset_paths')
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_file_searches
|
def spec_file_searches
|
||||||
@ -261,13 +296,15 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
|
|
||||||
def config_dir_or_pwd(dir)
|
def config_dir_or_pwd(dir)
|
||||||
found_dir = Dir.pwd
|
if (found = config_dir(dir)).empty?
|
||||||
|
found = [ Dir.pwd ]
|
||||||
if @options[:config]
|
|
||||||
found_dir = @options[:config][dir] || found_dir
|
|
||||||
end
|
end
|
||||||
|
|
||||||
[ found_dir ].flatten.collect { |dir| File.expand_path(dir) }
|
found
|
||||||
|
end
|
||||||
|
|
||||||
|
def config_dir(dir)
|
||||||
|
[ @options[:config] && @options[:config][dir] ].flatten.compact.collect { |dir| File.expand_path(dir) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_for_requested_specs(files)
|
def filter_for_requested_specs(files)
|
||||||
@ -279,5 +316,17 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def spec_helper
|
||||||
|
File.join(spec_dir, "helpers", "spec_helper")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module Jasmine::Headless
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register_engine(file_extension, template_class)
|
||||||
|
Jasmine::Headless::FilesList.register_engine(file_extension, template_class)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,12 +2,17 @@ require 'tilt/template'
|
|||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine::Headless
|
||||||
class JSTemplate < Tilt::Template
|
class JSTemplate < Tilt::Template
|
||||||
|
include Jasmine::Headless::FileChecker
|
||||||
self.default_mime_type = 'application/javascript'
|
self.default_mime_type = 'application/javascript'
|
||||||
|
|
||||||
def prepare ; end
|
def prepare ; end
|
||||||
|
|
||||||
def evaluate(scope, locals, &block)
|
def evaluate(scope, locals, &block)
|
||||||
if data['from="jhw"']
|
if bad_format?(file)
|
||||||
|
alert_bad_format(file)
|
||||||
|
return ''
|
||||||
|
end
|
||||||
|
if data[%r{^<script type="text/javascript"}]
|
||||||
data
|
data
|
||||||
else
|
else
|
||||||
file ? %{<script type="text/javascript" src="#{file}"></script>} : data
|
file ? %{<script type="text/javascript" src="#{file}"></script>} : data
|
||||||
|
@ -2,7 +2,12 @@ require 'sprockets/jst_processor'
|
|||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine::Headless
|
||||||
class JSTTemplate < Sprockets::JstProcessor
|
class JSTTemplate < Sprockets::JstProcessor
|
||||||
|
include Jasmine::Headless::FileChecker
|
||||||
def evaluate(*args)
|
def evaluate(*args)
|
||||||
|
if bad_format?(file)
|
||||||
|
alert_bad_format(file)
|
||||||
|
return ''
|
||||||
|
end
|
||||||
%{<script type="text/javascript">#{super}</script>}
|
%{<script type="text/javascript">#{super}</script>}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
14
lib/jasmine/headless/nil_template.rb
Normal file
14
lib/jasmine/headless/nil_template.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
require 'tilt/template'
|
||||||
|
require 'rainbow'
|
||||||
|
|
||||||
|
module Jasmine::Headless
|
||||||
|
class NilTemplate < Tilt::Template
|
||||||
|
|
||||||
|
def prepare ; end
|
||||||
|
|
||||||
|
def evaluate(scope, locals, &block)
|
||||||
|
return ''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -13,16 +13,21 @@ module Jasmine
|
|||||||
:remove_html_file => true,
|
:remove_html_file => true,
|
||||||
:runner_output_filename => false,
|
:runner_output_filename => false,
|
||||||
:jasmine_config => 'spec/javascripts/support/jasmine.yml',
|
:jasmine_config => 'spec/javascripts/support/jasmine.yml',
|
||||||
:report => false,
|
|
||||||
:do_list => false,
|
:do_list => false,
|
||||||
:full_run => true,
|
:full_run => true,
|
||||||
:enable_cache => true,
|
:enable_cache => true,
|
||||||
:files => []
|
:files => [],
|
||||||
|
:reporters => [ [ 'Console' ] ],
|
||||||
|
:quiet => false,
|
||||||
|
:use_server => false,
|
||||||
|
:server_port => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULTS_FILE = File.join(Dir.pwd, '.jasmine-headless-webkit')
|
DEFAULTS_FILE = File.join(Dir.pwd, '.jasmine-headless-webkit')
|
||||||
GLOBAL_DEFAULTS_FILE = File.expand_path('~/.jasmine-headless-webkit')
|
GLOBAL_DEFAULTS_FILE = File.expand_path('~/.jasmine-headless-webkit')
|
||||||
|
|
||||||
|
REPORT_DEPRECATED_MESSAGE = "--report is deprecated. Use --format HeadlessFileReporter --out <filename>"
|
||||||
|
|
||||||
def self.from_command_line
|
def self.from_command_line
|
||||||
options = new
|
options = new
|
||||||
options.process_command_line_args
|
options.process_command_line_args
|
||||||
@ -32,7 +37,10 @@ module Jasmine
|
|||||||
|
|
||||||
def initialize(opts = {})
|
def initialize(opts = {})
|
||||||
@options = DEFAULT_OPTIONS.dup
|
@options = DEFAULT_OPTIONS.dup
|
||||||
|
srand
|
||||||
|
@options[:seed] = rand(10000)
|
||||||
read_defaults_files
|
read_defaults_files
|
||||||
|
|
||||||
opts.each { |k, v| @options[k] = v if v }
|
opts.each { |k, v| @options[k] = v if v }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -51,7 +59,10 @@ module Jasmine
|
|||||||
when '--keep'
|
when '--keep'
|
||||||
@options[:remove_html_file] = false
|
@options[:remove_html_file] = false
|
||||||
when '--report'
|
when '--report'
|
||||||
@options[:report] = arg
|
warn REPORT_DEPRECATED_MESSAGE
|
||||||
|
|
||||||
|
add_reporter('File', arg)
|
||||||
|
add_reporter('Console')
|
||||||
when '--runner-out'
|
when '--runner-out'
|
||||||
@options[:runner_output_filename] = arg
|
@options[:runner_output_filename] = arg
|
||||||
when '--jasmine-config', '-j'
|
when '--jasmine-config', '-j'
|
||||||
@ -60,6 +71,22 @@ module Jasmine
|
|||||||
@options[:full_run] = false
|
@options[:full_run] = false
|
||||||
when '--list', '-l'
|
when '--list', '-l'
|
||||||
@options[:do_list] = true
|
@options[:do_list] = true
|
||||||
|
when '--quiet', '-q'
|
||||||
|
@options[:quiet] = true
|
||||||
|
when '--seed'
|
||||||
|
@options[:seed] = arg.to_i
|
||||||
|
when '--format', '-f'
|
||||||
|
add_reporter(arg)
|
||||||
|
when '--use-server'
|
||||||
|
@options[:use_server] = true
|
||||||
|
when '--server-port'
|
||||||
|
@options[:server_port] = arg.to_i
|
||||||
|
when '--out'
|
||||||
|
add_reporter_file(arg)
|
||||||
|
when '-h', '--help'
|
||||||
|
print_help
|
||||||
|
|
||||||
|
exit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -76,17 +103,103 @@ module Jasmine
|
|||||||
[ '--colors', '-c', GetoptLong::NO_ARGUMENT ],
|
[ '--colors', '-c', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--no-colors', GetoptLong::NO_ARGUMENT ],
|
[ '--no-colors', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--cache', GetoptLong::NO_ARGUMENT ],
|
[ '--cache', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--no-t stcache', GetoptLong::NO_ARGUMENT ],
|
[ '--no-cache', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--keep', GetoptLong::NO_ARGUMENT ],
|
[ '--keep', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--runner-out', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--runner-out', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--report', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--report', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--no-full-run', GetoptLong::NO_ARGUMENT ],
|
[ '--no-full-run', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--list', '-l', GetoptLong::NO_ARGUMENT ]
|
[ '--list', '-l', GetoptLong::NO_ARGUMENT ],
|
||||||
|
[ '--seed', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
|
[ '--format', '-f', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
|
[ '--out', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
|
[ '--use-server', GetoptLong::NO_ARGUMENT ],
|
||||||
|
[ '--server-port', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
|
[ '-h', '--help', GetoptLong::NO_ARGUMENT ],
|
||||||
|
[ '-q', '--quiet', GetoptLong::NO_ARGUMENT ]
|
||||||
)
|
)
|
||||||
|
|
||||||
command_line_args.each { |*args| process_option(*args) }
|
command_line_args.each { |*args| process_option(*args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reporters
|
||||||
|
file_index = 0
|
||||||
|
|
||||||
|
@options[:reporters].collect do |reporter, file|
|
||||||
|
output = [ reporter ]
|
||||||
|
if file
|
||||||
|
output << "report:#{file_index}"
|
||||||
|
output << file
|
||||||
|
file_index += 1
|
||||||
|
else
|
||||||
|
output << "stdout"
|
||||||
|
end
|
||||||
|
|
||||||
|
output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def file_reporters
|
||||||
|
reporters.find_all { |reporter| reporter[1]["report:"] }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def add_reporter(name, file = nil)
|
||||||
|
if !@added_reporter
|
||||||
|
@options[:reporters] = []
|
||||||
|
@added_reporter = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if (parts = name.split(':')).length == 2
|
||||||
|
name, file = parts
|
||||||
|
end
|
||||||
|
|
||||||
|
@options[:reporters] << [ name ]
|
||||||
|
|
||||||
|
add_reporter_file(file) if file
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_reporter_file(file)
|
||||||
|
@options[:reporters].last << file
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_help
|
||||||
|
options = [
|
||||||
|
[ '-c, --colors', 'Enable colors (default: disabled)' ],
|
||||||
|
[ '-nc, --no-colors', 'Disable colors' ],
|
||||||
|
[ '--cache', 'Enable cache (default: enabled)' ],
|
||||||
|
[ '--no-cache', 'Disable cache' ],
|
||||||
|
[ '--keep', 'Keep runner files on failure' ],
|
||||||
|
[ '--runner-out <filename>', 'Write runner to specified filename' ],
|
||||||
|
[ '-j, --jasmine-config <config file>', 'Jasmine Yaml config to use' ],
|
||||||
|
[ '--no-full-run', 'Do not perform a full spec run after a successful targeted spec run' ],
|
||||||
|
[ '--use-server', 'Load tests from an HTTP server instead of from filesystem' ],
|
||||||
|
[ '-l, --list', 'List files in the order they will be required' ],
|
||||||
|
[ '--seed <seed>', 'Random order seed for spec file ordering' ],
|
||||||
|
[ '-f, --format <reporter<:filename>>', 'Specify an output reporter and possibly output filename' ],
|
||||||
|
[ '--out <filename>', 'Specify output filename for last defined reporter' ],
|
||||||
|
[ '-q, --quiet', "Silence most non-test related warnings" ],
|
||||||
|
[ '-h, --help', "You're looking at it" ]
|
||||||
|
]
|
||||||
|
|
||||||
|
longest_length = options.collect(&:first).collect(&:length).max
|
||||||
|
|
||||||
|
puts <<-HELP
|
||||||
|
Usage: #{$0} [ options ] [ spec files ]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
#{options.collect { |option, description| " #{option.ljust(longest_length)} #{description}" }.join("\n")}
|
||||||
|
|
||||||
|
Available reporters:
|
||||||
|
Console Write out spec results to the console in a progress format (default)
|
||||||
|
Verbose Write out spec results to the console in a verbose format
|
||||||
|
File Write spec results in jasmine-headless-webkit ReportFile format
|
||||||
|
Tap Write spec results in TAP format
|
||||||
|
|
||||||
|
Add reporters to the jasmine.HeadlessReporter object to access them
|
||||||
|
(ex: jasmine.HeadlessReporter.Teamcity for the Teamcity reporter)
|
||||||
|
HELP
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -60,8 +60,13 @@ module Jasmine::Headless
|
|||||||
}.collect(&:filename).uniq.compact
|
}.collect(&:filename).uniq.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def seed
|
||||||
|
if seed = report.find { |entry| entry.respond_to?(:seed) }
|
||||||
|
seed.seed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
def last_total
|
def last_total
|
||||||
@report.reverse.find { |entry| entry.respond_to?(:total) }
|
@report.reverse.find { |entry| entry.respond_to?(:total) }
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,7 @@ module Jasmine::Headless
|
|||||||
autoload :Console, 'jasmine/headless/report_message/console'
|
autoload :Console, 'jasmine/headless/report_message/console'
|
||||||
autoload :Error, 'jasmine/headless/report_message/error'
|
autoload :Error, 'jasmine/headless/report_message/error'
|
||||||
autoload :Total, 'jasmine/headless/report_message/total'
|
autoload :Total, 'jasmine/headless/report_message/total'
|
||||||
|
autoload :Seed, 'jasmine/headless/report_message/seed'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
module Jasmine::Headless::ReportMessage
|
module Jasmine::Headless::ReportMessage
|
||||||
class Console
|
class Console
|
||||||
class << self
|
def self.new_from_parts(parts)
|
||||||
def new_from_parts(parts)
|
new(parts.first)
|
||||||
new(parts.first)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :message
|
attr_reader :message
|
||||||
|
14
lib/jasmine/headless/report_message/seed.rb
Normal file
14
lib/jasmine/headless/report_message/seed.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
module Jasmine::Headless::ReportMessage
|
||||||
|
class Seed
|
||||||
|
def self.new_from_parts(parts)
|
||||||
|
new(parts.first)
|
||||||
|
end
|
||||||
|
|
||||||
|
attr_reader :seed
|
||||||
|
|
||||||
|
def initialize(seed)
|
||||||
|
@seed = seed.to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,11 +1,9 @@
|
|||||||
module Jasmine::Headless::ReportMessage
|
module Jasmine::Headless::ReportMessage
|
||||||
class Spec
|
class Spec
|
||||||
class << self
|
def self.new_from_parts(parts)
|
||||||
def new_from_parts(parts)
|
file_info = parts.pop
|
||||||
file_info = parts.pop
|
|
||||||
|
|
||||||
new(parts.join(' '), file_info)
|
new(parts.join(' '), file_info)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :statement, :file_info
|
attr_reader :statement, :file_info
|
||||||
|
@ -4,11 +4,29 @@ require 'coffee-script'
|
|||||||
require 'rainbow'
|
require 'rainbow'
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
require 'erb'
|
||||||
require 'sprockets'
|
require 'sprockets'
|
||||||
|
|
||||||
|
|
||||||
module Jasmine
|
module Jasmine
|
||||||
module Headless
|
module Headless
|
||||||
|
class IndexHandler
|
||||||
|
class << self
|
||||||
|
attr_accessor :index
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(app)
|
||||||
|
@app = app
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
if env['PATH_INFO'] == '/'
|
||||||
|
return [ 302, { 'Location' => self.class.index }, [ 'Redirecting...' ] ]
|
||||||
|
end
|
||||||
|
|
||||||
|
@app.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Runner
|
class Runner
|
||||||
JASMINE_DEFAULTS = {
|
JASMINE_DEFAULTS = {
|
||||||
'spec_files' => [ '**/*[sS]pec.js' ],
|
'spec_files' => [ '**/*[sS]pec.js' ],
|
||||||
@ -25,21 +43,108 @@ module Jasmine
|
|||||||
|
|
||||||
attr_reader :options
|
attr_reader :options
|
||||||
|
|
||||||
class << self
|
def self.run(options = {})
|
||||||
def run(options = {})
|
new(options).run
|
||||||
options = Options.new(options) if !options.kind_of?(Options)
|
end
|
||||||
new(options).run
|
|
||||||
|
def self.server_port
|
||||||
|
return @server_port if @server_port
|
||||||
|
|
||||||
|
require 'socket'
|
||||||
|
|
||||||
|
count = 100
|
||||||
|
begin
|
||||||
|
port = select_server_port
|
||||||
|
|
||||||
|
socket = TCPSocket.new(server_interface, port)
|
||||||
|
socket.close
|
||||||
|
|
||||||
|
count -= 1
|
||||||
|
|
||||||
|
raise "Could not create server port after 100 attempts!" if count == 0
|
||||||
|
rescue Errno::ECONNREFUSED
|
||||||
|
@server_port = port
|
||||||
|
|
||||||
|
break
|
||||||
|
ensure
|
||||||
|
begin
|
||||||
|
socket.close if socket
|
||||||
|
rescue IOError
|
||||||
|
end
|
||||||
|
end while true
|
||||||
|
|
||||||
|
@server_port
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.server_port=(port)
|
||||||
|
@server_port = port
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.select_server_port
|
||||||
|
21000 + rand(10000)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.server_interface
|
||||||
|
'127.0.0.1'
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.server_uri
|
||||||
|
"http://#{server_interface}:#{server_port}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.server_spec_path
|
||||||
|
self.server_uri + '/__JHW__/'
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.ensure_server(options)
|
||||||
|
return if @server
|
||||||
|
|
||||||
|
require 'webrick'
|
||||||
|
require 'thread'
|
||||||
|
require 'rack'
|
||||||
|
require 'net/http'
|
||||||
|
|
||||||
|
port = server_port
|
||||||
|
|
||||||
|
@server = Thread.new do
|
||||||
|
Jasmine::Headless.warn "Powering up!"
|
||||||
|
|
||||||
|
app = Rack::Builder.new do
|
||||||
|
use IndexHandler
|
||||||
|
|
||||||
|
map '/__JHW__' do
|
||||||
|
run Rack::File.new(Dir.pwd)
|
||||||
|
end
|
||||||
|
|
||||||
|
map '/' do
|
||||||
|
run Rack::File.new('/')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rack::Handler::WEBrick.run(
|
||||||
|
app,
|
||||||
|
:Port => port,
|
||||||
|
:Logger => Logger.new(StringIO.new),
|
||||||
|
:AccessLog => [
|
||||||
|
[ StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
|
||||||
|
[ StringIO.new, WEBrick::AccessLog::REFERER_LOG_FORMAT ]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
while true do
|
||||||
|
begin
|
||||||
|
Net::HTTP.get(URI(server_uri))
|
||||||
|
break
|
||||||
|
rescue Errno::ECONNREFUSED => e
|
||||||
|
end
|
||||||
|
|
||||||
|
sleep 0.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
if !File.file?(RUNNER)
|
options = Options.new(options) if !options.kind_of?(Options)
|
||||||
$stderr.puts "No runner found, attempting to compile..."
|
|
||||||
Dir.chdir RUNNER_DIR do
|
|
||||||
system %{ruby extconf.rb}
|
|
||||||
end
|
|
||||||
raise NoRunnerError if !File.file?(RUNNER)
|
|
||||||
end
|
|
||||||
|
|
||||||
@options = options
|
@options = options
|
||||||
end
|
end
|
||||||
@ -59,28 +164,45 @@ module Jasmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def jasmine_command(*targets)
|
def jasmine_command(*targets)
|
||||||
[
|
command = [ RUNNER ]
|
||||||
RUNNER,
|
|
||||||
@options[:colors] ? '-c' : nil,
|
command << "-s #{options[:seed]}"
|
||||||
@options[:report] ? "-r #{@options[:report]}" : nil,
|
command << '-c' if options[:colors]
|
||||||
*targets
|
command << '-q' if options[:quiet]
|
||||||
].compact.join(" ")
|
|
||||||
|
options.file_reporters.each do |reporter, identifier, file|
|
||||||
|
command << "-r #{file}"
|
||||||
|
end
|
||||||
|
|
||||||
|
command += targets
|
||||||
|
command.compact.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
Jasmine::Headless::CacheableAction.enabled = @options[:enable_cache]
|
Jasmine::Headless::CacheableAction.enabled = @options[:enable_cache]
|
||||||
|
Jasmine::Headless.show_warnings = !@options[:quiet]
|
||||||
FilesList.reset!
|
FilesList.reset!
|
||||||
|
|
||||||
files_list = Jasmine::Headless::FilesList.new(
|
self.class.server_port = options[:server_port]
|
||||||
:config => jasmine_config,
|
|
||||||
:only => @options[:files]
|
|
||||||
)
|
|
||||||
|
|
||||||
@_targets = template_writer.write!(files_list)
|
@_targets = template_writer.write
|
||||||
run_targets = @_targets.dup
|
|
||||||
run_targets.pop if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
|
run_targets = absolute_run_targets(@_targets.dup)
|
||||||
|
|
||||||
|
if run_targets.length == 2
|
||||||
|
if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
|
||||||
|
run_targets.pop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
runner = lambda { system jasmine_command(run_targets) }
|
||||||
|
|
||||||
|
if options[:use_server]
|
||||||
|
wrap_in_server(run_targets, &runner)
|
||||||
|
else
|
||||||
|
runner.call
|
||||||
|
end
|
||||||
|
|
||||||
system jasmine_command(run_targets)
|
|
||||||
@_status = $?.exitstatus
|
@_status = $?.exitstatus
|
||||||
ensure
|
ensure
|
||||||
if @_targets && !runner_filename && (@options[:remove_html_file] || (@_status == 0))
|
if @_targets && !runner_filename && (@options[:remove_html_file] || (@_status == 0))
|
||||||
@ -88,6 +210,17 @@ module Jasmine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def absolute_run_targets(targets)
|
||||||
|
targets.flatten.collect do |target|
|
||||||
|
if options[:use_server]
|
||||||
|
target = self.class.server_spec_path + target
|
||||||
|
else
|
||||||
|
target = "file://" + File.expand_path(target)
|
||||||
|
end
|
||||||
|
target
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def runner_filename
|
def runner_filename
|
||||||
options[:runner_output_filename] || begin
|
options[:runner_output_filename] || begin
|
||||||
if (runner_output = jasmine_config['runner_output']) && !runner_output.empty?
|
if (runner_output = jasmine_config['runner_output']) && !runner_output.empty?
|
||||||
@ -98,11 +231,29 @@ module Jasmine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def files_list
|
||||||
|
@files_list ||= Jasmine::Headless::FilesList.new(
|
||||||
|
:config => jasmine_config,
|
||||||
|
:only => options[:files],
|
||||||
|
:seed => options[:seed],
|
||||||
|
:reporters => options.reporters
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def wrap_in_server(run_targets)
|
||||||
|
self.class.ensure_server(options)
|
||||||
|
IndexHandler.index = run_targets.last
|
||||||
|
|
||||||
|
Jasmine::Headless.warn "HTTP powered specs! Located at #{run_targets.join(' ')}"
|
||||||
|
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def jasmine_config_data
|
def jasmine_config_data
|
||||||
raise JasmineConfigNotFound.new("Jasmine config not found. I tried #{@options[:jasmine_config]}.") if !File.file?(@options[:jasmine_config])
|
raise JasmineConfigNotFound.new("Jasmine config not found. I tried #{@options[:jasmine_config]}.") if !File.file?(@options[:jasmine_config])
|
||||||
|
|
||||||
YAML.load_file(@options[:jasmine_config])
|
YAML.load(ERB.new(File.read(@options[:jasmine_config])).result(binding))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,11 +33,11 @@ module Jasmine::Headless
|
|||||||
end
|
end
|
||||||
|
|
||||||
def serialize(data)
|
def serialize(data)
|
||||||
MultiJson.encode(data)
|
MultiJson.dump(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unserialize(data)
|
def unserialize(data)
|
||||||
MultiJson.decode(data)
|
MultiJson.load(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,23 +1,3 @@
|
|||||||
module Digest
|
|
||||||
class JasmineTest
|
|
||||||
def self.file(file)
|
|
||||||
new
|
|
||||||
end
|
|
||||||
|
|
||||||
def file(file)
|
|
||||||
self
|
|
||||||
end
|
|
||||||
|
|
||||||
def hexdigest
|
|
||||||
'test'
|
|
||||||
end
|
|
||||||
|
|
||||||
def update(prefix)
|
|
||||||
self
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Jasmine
|
module Jasmine
|
||||||
module Headless
|
module Headless
|
||||||
class Task
|
class Task
|
||||||
@ -34,24 +14,9 @@ module Jasmine
|
|||||||
|
|
||||||
desc 'Run Jasmine specs headlessly'
|
desc 'Run Jasmine specs headlessly'
|
||||||
task(name) { run_rake_task }
|
task(name) { run_rake_task }
|
||||||
|
|
||||||
create_rails_compliant_task if defined?(Rails)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def create_rails_compliant_task
|
|
||||||
if Rails.respond_to?(:version) && Rails.version >= "3.1.0"
|
|
||||||
desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
|
|
||||||
task 'assets:precompile:for_testing' => :environment do
|
|
||||||
$stderr.puts "This task is deprecated and will be removed after 2012-01-01"
|
|
||||||
|
|
||||||
Rails.application.assets.digest_class = Digest::JasmineTest
|
|
||||||
|
|
||||||
Rake::Task['assets:precompile'].invoke
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def run_rake_task
|
def run_rake_task
|
||||||
case Jasmine::Headless::Runner.run(
|
case Jasmine::Headless::Runner.run(
|
||||||
:colors => colors,
|
:colors => colors,
|
||||||
|
@ -1,24 +1,32 @@
|
|||||||
require 'multi_json'
|
require 'multi_json'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
require 'forwardable'
|
||||||
|
|
||||||
module Jasmine::Headless
|
module Jasmine::Headless
|
||||||
class TemplateWriter
|
class TemplateWriter
|
||||||
attr_reader :runner
|
attr_reader :runner
|
||||||
|
|
||||||
|
extend Forwardable
|
||||||
|
|
||||||
|
def_delegators :runner, :files_list, :options
|
||||||
|
def_delegators :options, :reporters
|
||||||
|
|
||||||
def initialize(runner)
|
def initialize(runner)
|
||||||
@runner = runner
|
@runner = runner
|
||||||
end
|
end
|
||||||
|
|
||||||
def write!(files_list)
|
def write
|
||||||
output = [
|
output = [
|
||||||
[ all_tests_filename, files_list.files_to_html ]
|
[ all_tests_filename, files_list.files_to_html ]
|
||||||
]
|
]
|
||||||
|
|
||||||
output.unshift([filtered_tests_filename , files_list.filtered_files_to_html ]) if files_list.filtered?
|
output.unshift([filtered_tests_filename, files_list.filtered_files_to_html ]) if files_list.filtered?
|
||||||
|
|
||||||
output.each do |name, files|
|
output.each do |name, files|
|
||||||
File.open(name, 'w') { |fh| fh.print template_for(files, files_list.spec_file_line_numbers) }
|
template = template_for(files)
|
||||||
|
|
||||||
|
File.open(name, 'wb') { |fh| fh.print template }
|
||||||
end
|
end
|
||||||
|
|
||||||
output.collect(&:first)
|
output.collect(&:first)
|
||||||
@ -32,8 +40,24 @@ module Jasmine::Headless
|
|||||||
all_tests_filename.gsub(%r{\.html$}, '.filter.html')
|
all_tests_filename.gsub(%r{\.html$}, '.filter.html')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render
|
||||||
|
template_for(all_files)
|
||||||
|
end
|
||||||
|
|
||||||
|
def all_files
|
||||||
|
files_list.files_to_html
|
||||||
|
end
|
||||||
|
|
||||||
|
def jhw_reporters
|
||||||
|
reporters.collect do |reporter, output|
|
||||||
|
%{jasmine.getEnv().addReporter(new jasmine.HeadlessReporter.#{reporter}("#{output}"));}
|
||||||
|
end.join("\n")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def template_for(files, spec_lines)
|
def template_for(files)
|
||||||
|
spec_lines = files_list.spec_file_line_numbers
|
||||||
|
|
||||||
ERB.new(Jasmine::Headless.root.join('skel/template.html.erb').read).result(binding)
|
ERB.new(Jasmine::Headless.root.join('skel/template.html.erb').read).result(binding)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
16
lib/jasmine/headless/unique_asset_list.rb
Normal file
16
lib/jasmine/headless/unique_asset_list.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
module Jasmine::Headless
|
||||||
|
class UniqueAssetList < ::Array
|
||||||
|
def <<(asset)
|
||||||
|
raise InvalidUniqueAsset.new("Not an asset: #{asset.inspect}") if !asset.respond_to?(:logical_path)
|
||||||
|
|
||||||
|
super if !self.any? { |other| asset.pathname == other.pathname }
|
||||||
|
end
|
||||||
|
|
||||||
|
def flatten
|
||||||
|
self.collect(&:to_a).flatten
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class InvalidUniqueAsset < StandardError ; end
|
||||||
|
end
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
module Jasmine
|
module Jasmine
|
||||||
module Headless
|
module Headless
|
||||||
VERSION = "0.8.0"
|
VERSION = "0.9.0.rc.2"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
4
script/hooks/post-commit
Executable file
4
script/hooks/post-commit
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
penchant gemfile remote --switch-back
|
||||||
|
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
OLD_GIT_DIR=$GIT_DIR
|
OLD_GIT_DIR=$GIT_DIR
|
||||||
|
|
||||||
if [ "$(penchant gemfile-env)" != "remote" ]; then
|
if [ "$(penchant gemfile-env)" != "remote deployment" ]; then
|
||||||
unset GIT_DIR
|
unset GIT_DIR
|
||||||
penchant gemfile remote
|
penchant gemfile remote --deployment
|
||||||
GIT_DIR=$OLD_GIT_DIR
|
GIT_DIR=$OLD_GIT_DIR
|
||||||
git add Gemfile*
|
git add Gemfile*
|
||||||
fi
|
fi
|
||||||
|
@ -5,7 +5,7 @@ if File.file?('Gemfile.erb')
|
|||||||
|
|
||||||
Dir.chdir '..' do
|
Dir.chdir '..' do
|
||||||
File.readlines(File.join(pwd, 'Gemfile.erb')).find_all { |line| line[':git'] }.each do |line|
|
File.readlines(File.join(pwd, 'Gemfile.erb')).find_all { |line| line[':git'] }.each do |line|
|
||||||
repo = line[%r{:git => (['"])(.*)\1}, 2]
|
repo = line[%r{:git => (['"])([^'"]+)\1}, 2]
|
||||||
|
|
||||||
puts "Installing #{repo}"
|
puts "Installing #{repo}"
|
||||||
system %{git clone #{repo}}
|
system %{git clone #{repo}}
|
||||||
|
@ -6,22 +6,24 @@
|
|||||||
<script type="text/javascript" src="<%= Jasmine::Headless.root.join('vendor/assets/javascripts/prolog.js') %>"></script>
|
<script type="text/javascript" src="<%= Jasmine::Headless.root.join('vendor/assets/javascripts/prolog.js') %>"></script>
|
||||||
<%= files.join("\n") %>
|
<%= files.join("\n") %>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
if (window.JHW) { HeadlessReporterResult.specLineNumbers = <%= MultiJson.encode(spec_lines) %>; }
|
if (window.JHW) { HeadlessReporterResult.specLineNumbers = <%= MultiJson.dump(spec_lines) %>; }
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jasmine.getEnv().console = {
|
jasmine.getEnv().console = {
|
||||||
log: function(msg) { JHW.stdout.puts(msg) }
|
log: function(msg) { JHW.print('stdout', msg + "\n"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
window._onload = window.onload
|
window._onload = window.onload;
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
if (window._onload) { window._onload() }
|
if (window._onload && (window._onload != window.onload)) {
|
||||||
|
window._onload();
|
||||||
|
}
|
||||||
|
|
||||||
if (window.JHW) {
|
if (window.JHW) {
|
||||||
jasmine.getEnv().addReporter(new jasmine.HeadlessConsoleReporter());
|
<%= jhw_reporters %>
|
||||||
} else {
|
} else {
|
||||||
types = [ 'HtmlReporter', 'TrivialReporter' ];
|
types = [ 'HtmlReporter', 'TrivialReporter' ];
|
||||||
|
|
||||||
@ -32,6 +34,39 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var location = window.location.href;
|
||||||
|
|
||||||
|
var getLastModified = function(callback) {
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
var header;
|
||||||
|
|
||||||
|
http.open('HEAD', location, true);
|
||||||
|
|
||||||
|
http.onreadystatechange = function() {
|
||||||
|
if(http.readyState === http.DONE) {
|
||||||
|
callback(http.getResponseHeader('Last-Modified'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
http.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
getLastModified(function(currentLastModified) {
|
||||||
|
var checker;
|
||||||
|
checker = function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
getLastModified(function(newLastModified) {
|
||||||
|
if (currentLastModified != newLastModified) {
|
||||||
|
setTimeout(function() { window.location.reload(); }, 1000);
|
||||||
|
} else {
|
||||||
|
checker();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 3000);
|
||||||
|
};
|
||||||
|
|
||||||
|
checker();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
jasmine.getEnv().execute();
|
jasmine.getEnv().execute();
|
||||||
|
@ -1,160 +0,0 @@
|
|||||||
require 'spec_helper'
|
|
||||||
require 'tempfile'
|
|
||||||
|
|
||||||
describe "jasmine-headless-webkit" do
|
|
||||||
let(:report) { 'spec/report.txt' }
|
|
||||||
|
|
||||||
before do
|
|
||||||
FileUtils.rm_f report
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
FileUtils.rm_f report
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'success' do
|
|
||||||
it "should succeed with error code 0" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --report #{report}}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
report.should be_a_report_containing(1, 0, false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
describe 'success but with js error' do
|
|
||||||
it "should succeed with error code 0" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --report #{report}}
|
|
||||||
$?.exitstatus.should == 1
|
|
||||||
|
|
||||||
# returns are unpredictable due to changes in jasmine! >.<
|
|
||||||
# all we can do is ensure that we've actually failed
|
|
||||||
#
|
|
||||||
# report.should be_a_report_containing(0, 0, false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'failure' do
|
|
||||||
it "should fail with an error code of 1" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --report #{report}}
|
|
||||||
$?.exitstatus.should == 1
|
|
||||||
|
|
||||||
report.should be_a_report_containing(1, 1, false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'with console.log' do
|
|
||||||
it "should succeed, but has a console.log so an error code of 2" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml --report #{report}}
|
|
||||||
$?.exitstatus.should == 2
|
|
||||||
|
|
||||||
report.should be_a_report_containing(1, 0, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'with coffeescript error' do
|
|
||||||
it "should fail" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/coffeescript_error/coffeescript_error.yml --report #{report}}
|
|
||||||
$?.exitstatus.should == 1
|
|
||||||
|
|
||||||
File.exist?(report).should be_false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'tries to leave page' do
|
|
||||||
it "should not leave the page nor loop" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/leave_page/leave_page.yml --report #{report}}
|
|
||||||
$?.exitstatus.should == 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'tries to click a button' do
|
|
||||||
it "should not leave the page nor loop" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/click_button/click_button.yml --report #{report}}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
report.should be_a_report_containing(0, 0, false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'with filtered run' do
|
|
||||||
context "don't run a full run, just the filtered run" do
|
|
||||||
it "should succeed and run both" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --no-full-run --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
report.should be_a_report_containing(1, 0, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should use a file outside the normal test run and only run one" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_other_file.js}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
report.should be_a_report_containing(1, 0, false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "do both runs" do
|
|
||||||
it "should fail and not run the second" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml --report #{report} ./spec/jasmine/filtered_failure/failure_spec.js}
|
|
||||||
$?.exitstatus.should == 1
|
|
||||||
|
|
||||||
report.should be_a_report_containing(1, 1, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should succeed and run both" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
report.should be_a_report_containing(2, 0, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should succeed and run both, with the first having a console.log call" do
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success_with_console/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success_with_console/success_one_spec.js}
|
|
||||||
$?.exitstatus.should == 2
|
|
||||||
|
|
||||||
report.should be_a_report_containing(2, 0, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'files' do
|
|
||||||
it 'should list all the files that will be found' do
|
|
||||||
files = %x{bin/jasmine-headless-webkit -l -j spec/jasmine/success/success.yml}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
files.lines.to_a.should include(File.expand_path("./spec/jasmine/success/success.js\n"))
|
|
||||||
files.lines.to_a.should include(File.expand_path("./spec/jasmine/success/success_spec.js\n"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'runner-out' do
|
|
||||||
it 'should write out the runner HTML to the specified path and not run the test' do
|
|
||||||
runner_path = Tempfile.new('jhw')
|
|
||||||
runner_path.close
|
|
||||||
|
|
||||||
system %{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --runner-out #{runner_path.path}}
|
|
||||||
|
|
||||||
File.size(runner_path.path).should_not == 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'sprockets' do
|
|
||||||
it 'should pull in the code via sprockets' do
|
|
||||||
files = %x{bin/jasmine-headless-webkit -l -j spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
files.lines.to_a.should contain_in_order_in_file_list(
|
|
||||||
'vendor/assets/javascripts/jquery.js',
|
|
||||||
'templates/that.jst.ejs',
|
|
||||||
'templates/this.jst',
|
|
||||||
'assets/things/required.js',
|
|
||||||
'assets/things/code.js',
|
|
||||||
'assets/things/subcode/more_code.js',
|
|
||||||
'spec_helper.js',
|
|
||||||
'spec/things/code_spec.js'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
BIN
spec/files/UTF-8-test.txt
Normal file
BIN
spec/files/UTF-8-test.txt
Normal file
Binary file not shown.
13
spec/integration/randomization_spec.rb
Normal file
13
spec/integration/randomization_spec.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'randomize run order' do
|
||||||
|
let(:seed) { 100 }
|
||||||
|
|
||||||
|
it 'should randomize the run order' do
|
||||||
|
output = %x{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --seed #{seed}}
|
||||||
|
$?.exitstatus.should == 0
|
||||||
|
|
||||||
|
output.should include("--seed #{seed}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
22
spec/integration/specify_runner_file_spec.rb
Normal file
22
spec/integration/specify_runner_file_spec.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'specify runner in jasmine.yml' do
|
||||||
|
before do
|
||||||
|
File.unlink "spec/temp_out.html" if File.file?('spec/temp_out.html')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should randomize the run order' do
|
||||||
|
output = %x{bin/jasmine-headless-webkit -j spec/jasmine/runner_out_in_jasmine_yml/jasmine.yml}
|
||||||
|
$?.exitstatus.should == 2
|
||||||
|
|
||||||
|
output.should include("made it")
|
||||||
|
output.should include("1 test")
|
||||||
|
|
||||||
|
"spec/temp_out.html".should be_a_file
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
File.unlink "spec/temp_out.html" if File.file?('spec/temp_out.html')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
23
spec/integration/sprockets_spec.rb
Normal file
23
spec/integration/sprockets_spec.rb
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'sprockets' do
|
||||||
|
it 'should pull in the code via sprockets' do
|
||||||
|
files = %x{bin/jasmine-headless-webkit -l -j spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml}
|
||||||
|
$?.exitstatus.should == 0
|
||||||
|
files.lines.to_a.should contain_in_order_in_file_list(
|
||||||
|
'assets/application.js.erb: unsupported format',
|
||||||
|
'vendor/assets/javascripts/jquery.js',
|
||||||
|
'templates/that.jst.ejs',
|
||||||
|
'templates/this.jst',
|
||||||
|
'things/jquery.string.js',
|
||||||
|
'assets/things/required.js',
|
||||||
|
'assets/things/code.js',
|
||||||
|
'assets/things/subcode/more_code.js',
|
||||||
|
'spec_helper.js',
|
||||||
|
'spec/things/code_spec.js'
|
||||||
|
)
|
||||||
|
|
||||||
|
files.lines.to_a.any? { |line| line['assets/jquery.string.js: unsupported format'] }.should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
src_files:
|
src_files:
|
||||||
|
- spec/javascripts/support/jquery-1.6.2.min.js
|
||||||
- spec/jasmine/console_log/console_log.js
|
- spec/jasmine/console_log/console_log.js
|
||||||
|
|
||||||
spec_files:
|
spec_files:
|
||||||
|
0
spec/jasmine/noisy/file.js.erb
Normal file
0
spec/jasmine/noisy/file.js.erb
Normal file
8
spec/jasmine/noisy/noisy.yml
Normal file
8
spec/jasmine/noisy/noisy.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
src_dir: spec/jasmine/noisy
|
||||||
|
src_files:
|
||||||
|
- '**/*'
|
||||||
|
|
||||||
|
spec_dir: spec/jasmine/noisy
|
||||||
|
spec_files:
|
||||||
|
- '**/*'
|
||||||
|
|
2
spec/jasmine/noisy/other_file.js
Normal file
2
spec/jasmine/noisy/other_file.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
window.prompt("hello");
|
||||||
|
|
11
spec/jasmine/runner_out_in_jasmine_yml/jasmine.yml
Normal file
11
spec/jasmine/runner_out_in_jasmine_yml/jasmine.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
src_dir: spec/jasmine/runner_out_in_jasmine_yml
|
||||||
|
spec_dir: spec/jasmine/runner_out_in_jasmine_yml
|
||||||
|
|
||||||
|
src_files:
|
||||||
|
- "*.js"
|
||||||
|
|
||||||
|
spec_files:
|
||||||
|
- "*_spec.coffee"
|
||||||
|
|
||||||
|
runner_output: 'spec/temp_out.html'
|
||||||
|
|
2
spec/jasmine/runner_out_in_jasmine_yml/test.js
Normal file
2
spec/jasmine/runner_out_in_jasmine_yml/test.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
console.log("made it")
|
||||||
|
|
4
spec/jasmine/runner_out_in_jasmine_yml/test_spec.coffee
Normal file
4
spec/jasmine/runner_out_in_jasmine_yml/test_spec.coffee
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
describe 'this', ->
|
||||||
|
it 'should be true', ->
|
||||||
|
expect(true).toEqual(true)
|
||||||
|
|
2
spec/jasmine/two_files_from_src_files/app/app.js
Normal file
2
spec/jasmine/two_files_from_src_files/app/app.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
//= require app-file
|
||||||
|
//
|
7
spec/jasmine/two_files_from_src_files/jasmine.yml
Normal file
7
spec/jasmine/two_files_from_src_files/jasmine.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
src_dir: spec/jasmine/two_files_from_src_files/app
|
||||||
|
|
||||||
|
asset_paths:
|
||||||
|
- "spec/jasmine/two_files_from_src_files/vendor"
|
||||||
|
|
||||||
|
src_files: [ 'vendor.js', 'app.js' ]
|
||||||
|
|
0
spec/jasmine/two_files_from_src_files/vendor/vendor-file.js
vendored
Normal file
0
spec/jasmine/two_files_from_src_files/vendor/vendor-file.js
vendored
Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user