more stuff, like console.log error code and others

This commit is contained in:
John Bintz 2011-04-13 20:21:23 -04:00
parent a313b9bdfd
commit a582c6387b
19 changed files with 107 additions and 3 deletions

9
.autotest Normal file
View File

@ -0,0 +1,9 @@
Autotest.add_hook(:initialize) do |at|
at.add_mapping(%r{bin/.*}, true) do |filename|
at.files_matching(%r{spec/bin/.*})
end
at.add_mapping(%r{spec/jasmine/.*}, true) do |filename|
at.files_matching(%r{spec/bin/.*})
end
end

2
.gitignore vendored
View File

@ -5,4 +5,4 @@ pkg/*
Makefile Makefile
specrunner.moc specrunner.moc
specrunner.o specrunner.o
jasmine-webkit-specrunner ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner

1
.rspec Normal file
View File

@ -0,0 +1 @@
-c

View File

@ -2,3 +2,7 @@ source "http://rubygems.org"
# Specify your gem's dependencies in jasmine-headless-webkit.gemspec # Specify your gem's dependencies in jasmine-headless-webkit.gemspec
gemspec gemspec
gem 'rspec'
gem 'autotest'

1
autotest/discover.rb Normal file
View File

@ -0,0 +1 @@
Autotest.add_discovery { 'rspec2' }

View File

@ -64,7 +64,7 @@ HTML
File.open(target = "specrunner.#{$$}.html", 'w') { |fh| fh.print output } File.open(target = "specrunner.#{$$}.html", 'w') { |fh| fh.print output }
system %{#{File.join(gem_dir, 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner')} #{target}} system %{#{File.join(gem_dir, 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner')} #{target}}
status = ($? == 0) ? 0 : 1 status = $?.exitstatus
FileUtils.rm_f target FileUtils.rm_f target
exit status exit status

View File

@ -63,12 +63,14 @@ private:
QBasicTimer m_ticker; QBasicTimer m_ticker;
int m_runs; int m_runs;
bool hasErrors; bool hasErrors;
bool usedConsole;
}; };
HeadlessSpecRunner::HeadlessSpecRunner() HeadlessSpecRunner::HeadlessSpecRunner()
: QObject() : QObject()
, m_runs(0) , m_runs(0)
, hasErrors(false) , hasErrors(false)
, usedConsole(false)
{ {
m_page.settings()->enablePersistentStorage(); m_page.settings()->enablePersistentStorage();
connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(watch(bool))); connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(watch(bool)));
@ -112,6 +114,7 @@ void HeadlessSpecRunner::errorLog(const QString &msg, int lineNumber, const QStr
void HeadlessSpecRunner::log(const QString &msg) void HeadlessSpecRunner::log(const QString &msg)
{ {
usedConsole = true;
std::cout << "\033[0;32m" << "[console] " << "\033[m"; std::cout << "\033[0;32m" << "[console] " << "\033[m";
std::cout << qPrintable(msg); std::cout << qPrintable(msg);
std::cout << std::endl; std::cout << std::endl;
@ -160,7 +163,7 @@ void HeadlessSpecRunner::timerEvent(QTimerEvent *event)
if (hasElement(".runner.passed")) { if (hasElement(".runner.passed")) {
QWebElement desc = m_page.mainFrame()->findFirstElement(".description"); QWebElement desc = m_page.mainFrame()->findFirstElement(".description");
std::cout << "\033[0;32m" << "PASS: " << qPrintable(desc.toPlainText()) << "\033[m" << std::endl; std::cout << "\033[0;32m" << "PASS: " << qPrintable(desc.toPlainText()) << "\033[m" << std::endl;
QApplication::instance()->exit(0); QApplication::instance()->exit(usedConsole ? 2 : 0);
return; return;
} }

3
index.md Normal file
View File

@ -0,0 +1,3 @@
## here
whoa, it's headless

View File

@ -0,0 +1,25 @@
require 'spec_helper'
describe "jasmine-headless-webkit" do
describe 'success' do
it "should succeed with error code 0" do
%x{bin/jasmine-headless-webkit spec/jasmine/success/success.yml}
$?.exitstatus.should == 0
end
end
describe 'failure' do
it "should fail with an error code of 1" do
%x{bin/jasmine-headless-webkit spec/jasmine/failure/failure.yml}
$?.exitstatus.should == 1
end
end
describe 'with console.log' do
it "should succeed, but has a console.log so an error code of 2" do
%x{bin/jasmine-headless-webkit spec/jasmine/console_log/console_log.yml}
$?.exitstatus.should == 2
end
end
end

View File

@ -0,0 +1 @@
var success = 1;

View File

@ -0,0 +1,10 @@
src_files:
- spec/jasmine/console_log/console_log.js
spec_files:
- spec/jasmine/console_log/console_log_spec.js
src_dir: .
spec_dir: .

View File

@ -0,0 +1,7 @@
describe('console.log', function() {
it('should succeed, but with a console.log', function() {
console.log("hello");
expect(success).toEqual(1);
});
});

View File

@ -0,0 +1 @@
var failure = 0;

View File

@ -0,0 +1,9 @@
src_files:
- spec/jasmine/failure/failure.js
spec_files:
- spec/jasmine/failure/failure_spec.js
src_dir: .
spec_dir: .

View File

@ -0,0 +1,6 @@
describe('failure', function() {
it("should fail with error code of 1", function() {
expect(failure).toEqual(1);
});
});

View File

@ -0,0 +1 @@
var success = 1;

View File

@ -0,0 +1,9 @@
src_files:
- spec/jasmine/success/success.js
spec_files:
- spec/jasmine/success/success_spec.js
src_dir: .
spec_dir: .

View File

@ -0,0 +1,6 @@
describe('success', function() {
it("should be a success", function() {
expect(success).toEqual(1);
});
});

8
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,8 @@
specrunner = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner'
if !File.file?(specrunner)
Dir.chdir File.split(specrunner).first do
system %{ruby extconf.rb}
end
end