Skip to content

Instantly share code, notes, and snippets.

View distributedlife's full-sized avatar

Ryan Boucher distributedlife

View GitHub Profile
@distributedlife
distributedlife / first.coffee
Created September 20, 2012 13:15
notes for vidcast on when/why to mock and the value of separating concerns
describe "given a valiant hero", ->
describe "when she gets crushed by an anvil", ->
it "should play the death music", ->
it "should calculate the final score", ->
it "should update the leader board", ->
it "should play the death animation", ->
describe "when she falls into a pit of spikes", ->
it "should play the death music", ->
it "should calculate the final score", ->
@distributedlife
distributedlife / require_js_unbind.coffee
Created August 21, 2012 11:24
what to do when you are unsure of what mocked requirejs AMD modules you need to unbind
unbind_all_the_things = (requirejs) ->
defined = requirejs.s.contexts._.defined
requirejs.undef(module) for module in Object.keys(defined)
@distributedlife
distributedlife / bullet_view.js
Created August 1, 2012 11:49
How do I mock the dependency of the things under test?
define(["game/thing_view"], function(ThingView) {
return function(THREE, bullet) {
var _this = new ThingView(THREE, bullet, "/public/img/tank_bullet.png")
return _this;
}
});
@distributedlife
distributedlife / exhibit_a.js
Created July 16, 2012 09:37
How best to model thi
draw = function() {
painter.clear();
things.forEach(function(thing) {
if(thing.active) {
painter.draw(thing);
}
});
};
@distributedlife
distributedlife / rspec_include.rb
Created July 1, 2012 06:42
rspec include files in lib path
Dir["lib/*.rb"].each {|f| require File.join(File.dirname(__FILE__), "../", f)}
@distributedlife
distributedlife / tagtastic.rb
Created June 28, 2012 05:53
tagtastic specs
describe "tagtastic" do
it "should recurse all the folders lazily"
describe "in preparation mode" do
it "should remove images"
it "should calculate the musicbrainz poid"
it "should store the poid as originalfilename.poid"
it "should look up the musicbrainz data for the poid and store it in originalfilename.json"
it "should log all files with no poid"
end
@distributedlife
distributedlife / specaroony.rb
Created June 28, 2012 02:54
tapestry specs
describe "a photo" do
it "should have a resource location"
it "should have EXIF data"
it "can include one or more people"
end
describe "a stack" do
it "should have at least one photo"
it "should have at least one bubbled photo"
it "can have zero or more sub stacks"
@distributedlife
distributedlife / coverage_100p_bhahaha.rb
Created May 9, 2012 01:50
You fool, you foolish fool. 100% code coverage is dumb.
def reciprocal integer
1.0 / integer
end
describe 'reciprocal' do
it 'should return 1 over the integer' do
reciprocal(2).should == 0.5
end
end
Feature: Who cares?
Scenario: valid user accounts can log in
When I have a valid user account
Then I can login
@distributedlife
distributedlife / with_object.rb
Created April 11, 2012 12:51
Is this necessary?
def with object
yield(object)
end
#so I can do this:
with Project.create do |project|
Task.create(:project_id => project.id)
end