Functional tests with the CFWheels testing framework
We're doing some functions tests for cfwheels even though the main docs - http://code.google.com/p/cfwheels/wiki/TestingFramework - have only controller, model, view. Trying to test our showUserText() function alone failed because it was telling me it doesn't know anything about other functions it calls that are in fact core to CFWheels (stripTags, in this case).
Turned out the secret was instantiating a controller and tacking this function (which is in events/functions.cfm so available "everywhere") onto it, loc.controller.showUserText() style.
<cfcomponent extends="wheelsMapping.Test">
<cffunction name="setup">
<cfset loc.controller = controller(name="Feed")>
</cffunction>
<cffunction name="test_instagram_with_short_url">
<cfset loc.message = "This message will have an Instagram image embedded that originally had a short URL: http://instagr.am/p/SQeWUcL0UZ/">
<cfset loc.expected = '<div class="instagram-photo"><a href="http://instagr.am/p/SQeWUcL0UZ"><img src="http://instagr.am/p/SQeWUcL0UZ/media?size=m"></a></div>'>
<cfset assert("loc.controller.showUserText(loc.message) contains loc.expected")>
</cffunction>
<cffunction name="test_instagram_with_long_url">
<cfset loc.message = "This message will have an Instagram image embedded that originally had a short URL: http://instagram.com/p/SQeWUcL0UZ :-)">
<cfset loc.expected = '<div class="instagram-photo"><a href="http://instagr.am/p/SQeWUcL0UZ"><img src="http://instagr.am/p/SQeWUcL0UZ/media?size=m"></a></div>'>
<cfset assert("loc.controller.showUserText(loc.message) contains loc.expected")>
</cffunction>
</cfcomponent>
Comments
:)
this is a very slick idea!
Thank you Anthony!
And thank you for all your great work on CFWheels!
Post new comment