Permalink
Browse files

more stuff, like console.log error code and others

  • Loading branch information...
1 parent a313b9b commit a582c6387b6b1f5bdabb05c84d5ca7cc2cabdd9f @johnbintz committed Apr 14, 2011
View
@@ -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
View
@@ -5,4 +5,4 @@ pkg/*
Makefile
specrunner.moc
specrunner.o
-jasmine-webkit-specrunner
+ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner
View
1 .rspec
@@ -0,0 +1 @@
+-c
View
@@ -2,3 +2,7 @@ source "http://rubygems.org"
# Specify your gem's dependencies in jasmine-headless-webkit.gemspec
gemspec
+
+gem 'rspec'
+gem 'autotest'
+
View
@@ -0,0 +1 @@
+Autotest.add_discovery { 'rspec2' }
@@ -64,7 +64,7 @@ HTML
File.open(target = "specrunner.#{$$}.html", 'w') { |fh| fh.print output }
system %{#{File.join(gem_dir, 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner')} #{target}}
-status = ($? == 0) ? 0 : 1
+status = $?.exitstatus
FileUtils.rm_f target
exit status
@@ -63,12 +63,14 @@ private slots:
QBasicTimer m_ticker;
int m_runs;
bool hasErrors;
+ bool usedConsole;
};
HeadlessSpecRunner::HeadlessSpecRunner()
: QObject()
, m_runs(0)
, hasErrors(false)
+ , usedConsole(false)
{
m_page.settings()->enablePersistentStorage();
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)
{
+ usedConsole = true;
std::cout << "\033[0;32m" << "[console] " << "\033[m";
std::cout << qPrintable(msg);
std::cout << std::endl;
@@ -160,7 +163,7 @@ void HeadlessSpecRunner::timerEvent(QTimerEvent *event)
if (hasElement(".runner.passed")) {
QWebElement desc = m_page.mainFrame()->findFirstElement(".description");
std::cout << "\033[0;32m" << "PASS: " << qPrintable(desc.toPlainText()) << "\033[m" << std::endl;
- QApplication::instance()->exit(0);
+ QApplication::instance()->exit(usedConsole ? 2 : 0);
return;
}
View
@@ -0,0 +1,3 @@
+## here
+
+whoa, it's headless
@@ -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
+
@@ -0,0 +1 @@
+var success = 1;
@@ -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: .
+
@@ -0,0 +1,7 @@
+describe('console.log', function() {
+ it('should succeed, but with a console.log', function() {
+ console.log("hello");
+ expect(success).toEqual(1);
+ });
+});
+
@@ -0,0 +1 @@
+var failure = 0;
@@ -0,0 +1,9 @@
+src_files:
+ - spec/jasmine/failure/failure.js
+
+spec_files:
+ - spec/jasmine/failure/failure_spec.js
+
+src_dir: .
+spec_dir: .
+
@@ -0,0 +1,6 @@
+describe('failure', function() {
+ it("should fail with error code of 1", function() {
+ expect(failure).toEqual(1);
+ });
+});
+
@@ -0,0 +1 @@
+var success = 1;
@@ -0,0 +1,9 @@
+src_files:
+ - spec/jasmine/success/success.js
+
+spec_files:
+ - spec/jasmine/success/success_spec.js
+
+src_dir: .
+spec_dir: .
+
@@ -0,0 +1,6 @@
+describe('success', function() {
+ it("should be a success", function() {
+ expect(success).toEqual(1);
+ });
+});
+
View
@@ -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
+

0 comments on commit a582c63

Please sign in to comment.