Skip to content

Instantly share code, notes, and snippets.

@fivetanley
fivetanley / EntryListingViewSpec.js
Created August 10, 2012 06:04
EVEN MORE SINON FUN
define( function( require ) {
var EntryListingView = require( 'views/EntryListingView' )
, $ = require( 'jquery' )
describe('EntryListingView', function() {
var entryListingView
, id = 'entry'
, entry
#Brittle Example
Feature: Automatically Update the Chat View
Users should not have to refresh their browser to see the latest messages.
Scenario: I send a message
Given I am on the chatsite
#Lower-level. Describes exact actions a user will execute in his/her browser.
When I fill out the message body with "Hi everyone"
And I click the "Send" button
Then I should see "<example_username>Hi everyone" in the ChatView
@fivetanley
fivetanley / ChatController.spec.coffee
Created August 29, 2012 23:49
The worst dependency mock/stub api of all time
ChatController = module.isolate(__dirname + '/../../lib/controllers/chat_controller' )
validator = ChatController.dependencies.find( /validator\S+index\.js/ )
describe 'ChatController', ->
sockets =
foo: {}
baz: 'foo'
bar: 'baz'
@fivetanley
fivetanley / trailingwhitespace.vim
Created August 31, 2012 13:33
character for trailing whitespace
set list
set listchars=trail:~ " Tilda as trailing whitespace character
@fivetanley
fivetanley / using_require_callback.html
Created August 31, 2012 15:58
How do you run jasmine?
<!-- blah blah, include jasmine / jquery, require.js, sinon, etc -->
<script type='text/javascript'>
require( [ 'test1', 'test2', 'test3' ], function() { jasmineEnv.execute() } );
</script>
@fivetanley
fivetanley / .vimrc
Created September 7, 2012 18:16
vimrc
set encoding=utf-8
set fillchars+=stl:\ ,stlnc:\
set nocp
" Vundle packages
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
@fivetanley
fivetanley / example_spec.js
Created September 20, 2012 23:54
support file for mocha tests
// requirejs global - hm....
define( function( require ) {
var support = require( 'support' )
// chai js loaded with sinon-chai and chai-jquery
, expect = support.expect
// sinon.js stub function. I also have spy and mock functions available
// on the support object
, stub = support.stub
, REPL = require( 'models/repl' )
@fivetanley
fivetanley / Main.java
Created September 21, 2012 06:01
loljava
public class Main {
public static void main( String[] args ) {
System.out.println( "hello world" );
}
}
@fivetanley
fivetanley / repl_view.js
Created September 22, 2012 19:02
repl view
define( function( require ) {
var Backbone = require( 'backbone' )
, _ = require( 'underscore' )
, $ = require( 'jquery' )
function createListItem( content, domClass) {
return $( '<li class="' + domClass + '">' + content + '</li>' )
}
@fivetanley
fivetanley / an_example_view_model.js
Created September 27, 2012 16:59
framework maybe?
define( function( require ) {
var framework = require( 'framework' )
, prototype
prototype = {
// self is always passed as the last argument to make functions re-usable
// and remove confusing `this` semantics
constructor: function( options, self ) {
self.model = options.model