Skip to content

Instantly share code, notes, and snippets.

View diamond_spec.js
var net = require('net');
var sys = require('sys');
var events = require('events');
var Diamond = function(){};
var Async = {}
Async.test_events = new events.EventEmitter();
Async.test = function(before_test_callback,test_callback) {
before_test_callback.apply(this);
View code
Ledger.prototype.server = undefined;
Ledger.prototype.halt_service = function() {
this.server.removeAllListeners('request');
this.server.removeAllListeners('listening');
this.server.close();
};
Ledger.prototype.service = function() {
var self = this;
var http = require('http');
var sys = require('sys');
View pat's thing
actionmailer (2.3.8, 2.3.5)
actionpack (2.3.8, 2.3.5)
activerecord (2.3.8, 2.3.5)
activeresource (2.3.8, 2.3.5)
activesupport (2.3.8, 2.3.5)
builder (2.1.2)
cucumber (0.7.3)
cucumber-rails (0.3.1)
culerity (0.2.10)
View col.js
Ledger.prototype.collection = function(callback) {
var client = new DStore('experiment',new Server("127.0.0.1", 27017, {},{strict:true}));
client.open(function() {
client.createCollection('ledger', function(err, collection) {
client.collection('ledger', function(err, collection) {
callback.apply(this,[err,collection,client]);
});
});
});
};
View --- out
"POST"
{"href":"/","pathname":"/"}
{"host":"ledger.robotarmyma.de:7001","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3","accept":"text/javascript, application/javascript, */*","accept-language":"en-us,en;q=0.5","accept-encoding":"gzip,deflate","accept-charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","keep-alive":"115","connection":"keep-alive","content-type":"application/x-www-form-urlencoded; charset=UTF-8","referer":"http://ledger.robotarmyma.de:3000/public/test/index.html","content-length":"91","origin":"http://ledger.robotarmyma.de:3000","pragma":"no-cache","cache-control":"no-cache"}
";jsonp1275368382519({\"pony\":\"cake\",\"name\":\"biscuit\"});"
View ledger_service_test.js
var http = require('http');
exports.test_ = function(test){
var client = http.createClient(7001, 'localhost');
var jpost = {name:'A Thing', value: "A Value"};
var request = client.request('POST', '/?callback=json_test_data&json='+JSON.stringify(jpost) ,{'host': 'localhost'});
request.addListener('response', function (response) {
response.setEncoding('utf8');
expect(response.statusCode).toEqual(200);
ok(response.headers["content-type"] == 'application/json;charset=utf-8', 'content-type set');
ok(response.headers["Access-Control-Allow-Origin"] != undefined, 'Access-Control-Allow-Origin exists');
View test.rb
callOptions = { :channel => "VOICE",
:answerOnMedia => false,
:timeout => 30.0,
:callerID => applicationCallerID
}
sayOptions = {:voice => "kate"}
conferenceOptions = { :mute => false,
View t.rb
describe ‘Fans Are Callable By Bands” do
it “band has a fan” do
a = Fan.create(:name => ‘Peter’ , :phone => ‘1231231’)
b = Band.find_by_name(’Rolling Stones’)
b.fans << a
b.save
a.reload
a.bands.should include b
end
end
@robotarmy
robotarmy / Fake Web Helper.rb
Created Jul 9, 2010
Cache Fake Web Content to Disk and Register a URI
View Fake Web Helper.rb
# Example
# fan = Factory(:fan)
# FakeWeb.register(:get,"http://www.google.com/",fan.class)
# fan.visit_google #successive calls read cache
#
# recommended to put into spec/support
#
require 'fakeweb'
require 'open-uri'
View gist:628697
test "has one user status" do
r = make_review_with_book
assert {
r.user_status == nil
}
us = UserStatus.make(:user => r.user, :book => r.book)
assert {
r.user_status.user == r.user
}
us2 = UserStatus.make(:user => r.user, :book => r.book)