Skip to content

Instantly share code, notes, and snippets.

View bittersweetryan's full-sized avatar

Ryan Anklam bittersweetryan

View GitHub Profile
@bittersweetryan
bittersweetryan / gist:1620990
Created January 16, 2012 13:56
Blog Post - Ordered Test Decorator
<cfcomponent extends="mxunit.framework.TestCase"
mxunit:decorators=mxunit.framework.decorators.OrderedTestDecorator>
...
</cfcomponent>
@bittersweetryan
bittersweetryan / gist:1620993
Created January 16, 2012 13:57
Blog Post - Ordered Test Decorator
<cfscript> //ignore, just here to get syntax coloring
/**
*@order 1
*/
public void function testIfVariableExists() {
assertEquals(isDefined("someVariableWithALongName") ,"__");
}
/**
*@order 2
@bittersweetryan
bittersweetryan / gist:1621002
Created January 16, 2012 13:58
Blog Post - Ordered Test Decorator
<cffunction name="testIsQuery" returntype="void" output="false" order="1">
<cfset var myQry = buildQueryObj()>
<!--- Check that a variable is a query --->
<cfset assertEquals(IsQuery(myQry),"___")>
</cffunction>
<cffunction name="testGettingQueryRecordCount" returntype="void" output="false" order="2">
<cfset var myQry = buildQueryObj()>
<!--- The total number of records in a returned query can be accessed using the recordcount --->
<cfset assertEquals(myQry.recordCount,"___")>
@bittersweetryan
bittersweetryan / gist:1752110
Created February 6, 2012 13:40
coldfusion boolean blog post
<cfscript>
if(var1 AND var2){ resultingVar = true;}else{ resultingVar = false;}
</cfscript>
@bittersweetryan
bittersweetryan / gist:1752117
Created February 6, 2012 13:41
Boolean blog post
<cfscript>
anotherVar = (var1 AND var2) ? true : false ; //cf9+ only
</cfscript>
@bittersweetryan
bittersweetryan / gist:1752127
Created February 6, 2012 13:42
Boolean blog post
<cfscript>
anotherVar = var1 &amp;&amp; var2; //cf9+anotherVar = var1 AND var2; //cf8-
</cfscript>
@bittersweetryan
bittersweetryan / gist:1830607
Created February 14, 2012 21:29
TransactionRollbackDecorator
<cfscript>//only for coloring
/**
* @mxunit:decorators mxunit.framework.decorators.TransactionRollbackDecorator
*/
component extends="mxunit.framework.TestCase" hint=""{
.
.
public void testSomething(){
//add,update,delete database
assertEquals(); //or any other assertion
@bittersweetryan
bittersweetryan / gist:1830655
Created February 14, 2012 21:36
Fun Unit Test
public void function testAuthenticatingUserWithWrongPassword(){
createUser();
user.setPassword("iLoveBieber");
assertTrue(user.authenticate());
}
@bittersweetryan
bittersweetryan / gist:1857045
Created February 18, 2012 02:44
map in coldfusion zeus
<cfscript>
public Array function map(Array arr,Function fn)
output=false {
//this is the new array that will hold the results
//of applying the function to each element of the array
var ret = [];
//use the new for-in construct to loop through each
//item in the array
for(ele in arr){
User = Backbone.Model.extend({
defaults: function(){
return{
"contact.firstName" : "",
"contact.lastName" : ""
};
},
url: "user"
});