Skip to content

Instantly share code, notes, and snippets.

View lightsofapollo's full-sized avatar

James Lal lightsofapollo

View GitHub Profile
@lightsofapollo
lightsofapollo / gist:1353018
Created November 9, 2011 21:03
Validation Architecture
PSI.Validator = function(){
this.init.apply(this, arguments);
};
PSI.Validators.Presence = function(){
this.init.apply(this, arguments);
};
PSI.Validators.Presence = YAHOO.lang.augmentObject({
@lightsofapollo
lightsofapollo / gist:1541788
Created December 30, 2011 22:32
Simple PHP BDD runner
<?php
/**
This is what I had in mind while thinking about a spec framework for PHP.
It is more verbose then other languages but its all PHP and should be easy enough to augment.
I admit I wrote this without any thought to compatibility with anything else.
*/
//Contexts (befores, afters and shoulds are executed within a context).
@lightsofapollo
lightsofapollo / gist:1577413
Created January 8, 2012 05:59
Jasmine reporter to find slow running tests
SlowDescribeReporter.prototype = {
threshold: 400,
reportRunnerStarting: function(runner){
var i, len, suites = runner.suites_, self = this;
this.topLevels = {};
for(i = 0, len = suites.length; i < len; i++){
(function(exec){
@lightsofapollo
lightsofapollo / gist:1998107
Created March 8, 2012 02:16
lets for javascript tests??
var SubjectClass = require('subject-class');
describe("NewLets", function(){
var subject;
stage('subject', function(){
subject = new SubjectClass;
});
@lightsofapollo
lightsofapollo / setup.md
Created April 18, 2012 21:56
Instructions

Gaia + Test Agent

You will need node & npm for the full demo. You only need a browser to execute the tests but for full reporting/file watching features you need the server.

Tested for node 0.4.9, ~0.6

0

You will need my branch:

127.0.0.1 gaiamobile.org
127.0.0.1 homescreen.gaiamobile.org
127.0.0.1 dialer.gaiamobile.org
127.0.0.1 sms.gaiamobile.org
127.0.0.1 browser.gaiamobile.org
127.0.0.1 maps.gaiamobile.org
127.0.0.1 camera.gaiamobile.org
127.0.0.1 gallery.gaiamobile.org
127.0.0.1 video.gaiamobile.org
127.0.0.1 market.gaiamobile.org
@lightsofapollo
lightsofapollo / gist:2474079
Created April 23, 2012 21:45
Marionette backend api
backend.send({
type: 'newSession',
to: 'connection1'
}, function(err, data){
//err for connection issues not errors sent by the server
//data is the json response.
});
@lightsofapollo
lightsofapollo / xhr.js
Created April 24, 2012 19:58
xhr wrapper (modern browsers only)
/**
* Make an XHR request accepts the following options
*
* method: (String) GET, POST, etc..
* url: (String) http://...
* async: (Boolean)
* success: (Callback) fired on success (get xhr object)
* error: (Callback) fired on error (get xhr object)
* complete: (Callback) fired on both error and success (gets xhr object)
* headers: (Object) list of headers
const CC = Components.Constructor;
const LocalFile = CC('@mozilla.org/file/local;1',
'nsILocalFile',
'initWithPath');
const ScriptableInputStream = CC(
"@mozilla.org/scriptableinputstream;1",
"nsIScriptableInputStream");
Components.utils.import('resource:///modules/devtools/dbg-client.jsm');
suite('myclass', function test(){
test('#myMethod', function someName(){
//...
});
});