Skip to content

Instantly share code, notes, and snippets.

View MandarinConLaBarba's full-sized avatar

Mandarin Drummond MandarinConLaBarba

View GitHub Profile
### Keybase proof
I hereby claim:
* I am MandarinConLaBarba on github.
* I am mandarin (https://keybase.io/mandarin) on keybase.
* I have a public key whose fingerprint is 9D29 1E19 F4F2 60EC 40C0 7C28 AFFC 5FDE 2071 6835
To claim this, I am signing this object:
mandarin@Tyrell:~/code/sebastian>mocha test/index.js
․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
✔ 66 tests complete (53 ms)
require.config({
"baseUrl" : "/base",
//paths to the stuff Testacular has loaded into the server, but not included in the page
"paths" : {
"jquery" : "vendor/jquery/jquery",
"chai" : "vendor/chai/chai",
"underscore" : "vendor/underscore-amd/underscore",
"sinon" : "vendor/sinon/sinon"
},
//Some shims..
// base path, that will be used to resolve files and exclude
basePath = '';
// list of files / patterns to load in the browser
files = [
MOCHA,
MOCHA_ADAPTER,
REQUIRE,
REQUIRE_ADAPTER,
(function(root, enqueue) {
// Set up appropriately for the environment.
if (typeof exports !== 'undefined') {
// Node/CommonJS, need jQuery-deferred instead of regular jQuery
enqueue(
require('jquery-deferred'),
require("underscore"),
require('sinon'),
require('should'),
require('../sebastian').flow);
describe("flows.example.splash", function() {
describe("steps", function() {
describe("login-user", function() {
beforeEach(function() {
//Get the step
var target = sebastian.flow("flows.example.splash").step("login-user"),
sebastian.flow("flows.examples.splash")
.step("get-form-data", function() {
var userName = this.view.$el.find('#txtUserName').val(),
password = this.view.$el.find('#txtPassword').val();
return $.Deferred().resolve(userName, password);
})
.step("login-user", function(userName, password) {
this.user.set("userName", userName);
var userName = view.$el.find('#txtUserName').val(),
password = view.$el.find('#txtPassword').val();
$.when(user.login())
.done(function() {
$.when(user.fetch())
.done(function() {
if (user.get("isAdmin")) {
view.showAdminPanel();
}
@MandarinConLaBarba
MandarinConLaBarba / gist:5055681
Created February 28, 2013 10:16
Sebastian first example
sebastian.flow("flows.examples.first")
.step("one", function() {
console.log("Welcome...");
})
.step("two", function() {
console.log("...to Sebastian.");
})
.begin();
@MandarinConLaBarba
MandarinConLaBarba / gist:4533303
Last active December 31, 2021 22:24
How to spy on node's require() w/ sinon.js
//If you need to spy or stub the global require function in node.js, don't try to spy on the require function itself..you aren't going //to be successful.
//Instead, spy on the require.extensions object like so:
var spies = {};
spies.require = sinon.spy(require.extensions, '.js');
//Then when you need to assert you can do stuff like:
spies.require.firstCall.args[1].should.include("path/to/some/module");