Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
V. busy with Ably, building a great team 🚀

Matthew O'Riordan mattheworiordan

💭
V. busy with Ably, building a great team 🚀
View GitHub Profile
View qunit_test.js
module("Calculator");
test('calculator can perform basic operations', 2, function() {
var calc = new Calculator();
equals (calc.sum(5,10), 15, 'Simple addition');
equals (calc.multiple(5,5), 25, 'Simple multiplication');
});
test('AJAX addition operation', 2, function() {
stop(5000); // wait for up to 5 seconds
@mattheworiordan
mattheworiordan / value_for_undefined_key.js
Created Jul 29, 2011
Use case for valueForUndefinedKey error raised on simple close call to Window
View value_for_undefined_key.js
var win = Titanium.UI.createWindow({
fullscreen: true,
backgroundColor: '#666',
url: 'value_for_undefined_key_subwindow.js'
});
win.addEventListener('ready', function() {
// win.close causes an error only if called immediately after window is created
win.close();
});
@mattheworiordan
mattheworiordan / features|focus_test.feature
Created Aug 18, 2011
Capybara-Webkit focus on an element test that fails
View features|focus_test.feature
Feature: Capybara Webkit focus test
In order to show that Capybara Webkit does not allow an element to maintain focus
I created this feature
Which anyone can try
@javascript
Scenario: Run demo page
When I am on the capybara demo page
Then I should see a successful result
@mattheworiordan
mattheworiordan / focus_test.feature
Created Aug 23, 2011
:focus pseudo selector fix for Capybara-webkit and or Selenium with Cucumber
View focus_test.feature
Feature: Capybara Webkit and Selenium :focus test
In order to show that Capybara Webkit and Selenium do not allow an element to maintain focus
I created this feature
Which anyone can try
@selenium
Scenario: Run demo page with Selenium
When I am on the capybara demo page
And I fill in "inpt" with "Test snapshot"
Then I should see a successful result
@mattheworiordan
mattheworiordan / jquery.focus.test-fix.js
Created Aug 23, 2011
Fix for :focus pseudo selector when browser does not have focus
View jquery.focus.test-fix.js
/**
* JQuery tries to use native CSS selectors instead of the Sizzle selector
* engine for performance reasons.
*
* This causes problems when trying to test intefaces using the
* :focus pseudo selector as unless the web page and browser window
* has the focus, all elements are considered to be without focus.
* Checking for :focus in Selenium or Capybara tests therefore fail if
* using JQuery or Sizzle.
*
@mattheworiordan
mattheworiordan / QUnit.chain
Created Sep 1, 2011 — forked from filmaj/QUnit.chain
Tiny QUnit async test helper, eliminates pyramid code in async tests with multiple assertions, each requiring its own delay.
View QUnit.chain
/**
* testAsyncStepsWithPause
* Executes any number of async Qunit tests with a pause between each step
*
* Author: Matthew O'Riordan, http://mattheworiordan.com
*
* Params:
* @timeToWait: milliseconds between running method and running tests
* @methods: 1+ function arguments passed in the format:
* function() {
View fiddle.html
<p>
An alert box with Hello should have displayed
</p>
@mattheworiordan
mattheworiordan / compile.rb
Created Feb 15, 2012
Rails assets compilation using the correct RAILS_ENV into a Git branch
View compile.rb
#!/usr/bin/env ruby
##
# Compile script for Rails assets that puts the assets into their [environment] branch
# thus not polluting the master branch with the files in public/assets that only
# apply to that environment. See https://github.com/rails/sass-rails/issues/93#issuecomment-3982582
#
# Usage: ./compile [environment]
# supported environments
@mattheworiordan
mattheworiordan / transport.py
Created Feb 23, 2012
paramiko fix for bees with machine guns
View transport.py
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
#
# This file is part of paramiko.
#
# Paramiko is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
@mattheworiordan
mattheworiordan / loadspeed.js
Created Oct 24, 2012
PhantomJS working example
View loadspeed.js
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit();
}
t = Date.now();