Skip to content

Instantly share code, notes, and snippets.

View ragaskar's full-sized avatar

Rajan Agaskar ragaskar

View GitHub Profile
/**
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
*/
@ragaskar
ragaskar / aggregates_current_organization.rb
Last active August 29, 2015 13:57
CloudController Repository Pattern
module Aggregate
class CurrentOrganization
attr_reader :organization, :spaces, :account
def initialize(attrs)
@organization = attrs.fetch(:organization)
@spaces = attrs.fetch(:spaces)
@account = attrs.fetch(:account)
end
@ragaskar
ragaskar / gist:3ec13eea2bdce1f07ad3
Created May 21, 2014 19:04
Getting Rails HTML from Controllers (without instantiation) programmatically in a rake task
session = ActionDispatch::Integration::Session.new(Rails.application)
session.get('/some/url/your/app/has')
body = session.response.body
######################
# A tool for facilitating retros (esp. ones with remote attendees)
# Usage:
# 1. new up a rando object in an irb session
# 2. Add everyone who arrives at the retro by passing strings to the .add method (can take one or many names)
# 3. Ask everyone to write topics on notecards (one topic per card). This can be themed ('one thing to change & why'), or not ('happy', 'meh', 'sad')
# 4. call .next, ask that person to read their card aloud. Use a timer + do a Roman vote to continue on the topic every 5 min.
######################
class Rando
@ragaskar
ragaskar / GameSpec.js
Created June 30, 2011 12:03
Refactored Baseketball and Football specs
describe("games", function() {
subject("game", function() { game });
describe("Basketball Game", function() {
given(game, function() { new BasketballGame(); });
its("fieldGoal.points", function() { expect.toEqual(2); });
})
describe("Football Game", function() {
given(game, function() { new FootballGame(); });
its("fieldGoal.points", function() { expect.toEqual(3); });
});
@ragaskar
ragaskar / spec.rake
Created July 2, 2011 21:24
Kill spork when running rake spec (place in lib/tasks)
task :kill_spork do
spork_processes = `ps aux | grep spork | egrep -v grep | awk '{print $2}'`.split("\n")
spork_processes.each do |process|
system("kill #{process}")
end
end
task :spec => [:kill_spork, :cucumber]
@ragaskar
ragaskar / show-branch-info
Created August 5, 2011 12:46
Show Remote Branch info
#!/bin/sh
for k in `git branch -r|awk '{print $1}'`;do echo `git show --pretty=format:"%Cgreen%ci %Cblue%cr %Cred%cn %Creset" $k|head -n 1`\\t$k;done|sort -r
echo "If you're unable to remove a branch, it may already be gone from the remote. Try git remote prune origin (git remote prune --dry-run origin) to see what remote branch references will be deleted"
/*
We have two classes: resultRenderer and dbQuery
resultRenderer will ask dbQuery to perform a database query, and asyncronously receives the results
*/
function resultRenderer(query) { this._query = query }
resultRenderer.prototype = {
queryResultsAndRender: function () {
this._query.runQueryAsync(this.renderResults.bind(this));
@ragaskar
ragaskar / spec_helper.js
Created November 3, 2011 14:53
Fuzzy output matcher (untested)
beforeEach(function() {
this.addMatchers({
toEqualSomethingIn : function toEqualSomethingIn(possibleOutputs) {
this.message = function() {
return [
"Expected " + this.actual + " to be one of the following: "+ possibleOutputs,
"Expected " + this.actual + " not to be one of the following: "+ possibleOutputs + ", but it was"
];
};
return (possibleOutputs.indexOf(this.actual) != -1)
@ragaskar
ragaskar / 1-before_spec.rb
Created November 19, 2011 16:09 — forked from richievos/1-before_spec.rb
Spectastrophe #1
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Something doppelganger" do
describe "RailCar" do
let(:gateway) { RailCar.new :login => "a", :password => "b" }
describe "#commit" do
let(:response) { railcar.send :commit, request, {} }
describe "response" do