Skip to content

Instantly share code, notes, and snippets.

View sarahhenkens's full-sized avatar

Sarah Henkens sarahhenkens

View GitHub Profile
module GraphQL
module Relay
module Cursor
# The encoder/decoder for the cursor used in our smart GraphQL connections
class DefaultEngine
def encode(data)
Base64.strict_encode64(JSON.generate(data))
end
def decode(cursor)
@sarahhenkens
sarahhenkens / gist:3717980
Created September 13, 2012 21:53
Assert to test that 2 time's are equal to each other within a margin of x seconds
/**
* Assert that 2 datetime strings are equal within a margin
*
* @param string $expected
* @param string $result
* @param integer $margin The margin in seconds
* @param string $message optional message
* @return boolean
*/
public function assertDateEquals($expected, $result, $margin = 1, $message = '') {
@sarahhenkens
sarahhenkens / gist:2855448
Created June 1, 2012 22:14
Child class of AMQPConnection cannot access its own attributes
<?php
class MockAMQPConnection extends AMQPConnection {
protected $foo = 'bar';
public function getFoo() {
return $this->foo;
}
}
$mock = new MockAMQPConnection();