ColdBox Platform v3.8.0

coldbox.system.testing
Class Expectation

WEB-INF.cftags.component
        extended by coldbox.system.testing.Expectation

public class Expectation
extends WEB-INF.cftags.component

******************************************************************************* Copyright 2005-2009 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.luismajano.com | www.ortussolutions.com ******************************************************************************* The Expectation CFC holds a current expectation with all the required matcher methods to provide you with awesome BDD expressions and testing.

Property Summary
Type Property & Description Default Serializable Required
 any assert


Attributes:
true false
 any mockbox


Attributes:
true false
 any spec


Attributes:
true false
 
Constructor Summary
init(any spec, any assertions, any mockBox)
          Constructor
 
Method Summary
 any GETASSERT()
 any GETMOCKBOX()
 any GETSPEC()
 Expectation SETASSERT(any assert)
 Expectation SETMOCKBOX(any mockbox)
 Expectation SETSPEC(any spec)
 any _not()
          Set the not bit to TRUE for this expectation
 any fail([any message=''])
          Fail an assertion
 any onMissingMethod(any missingMethodName, any missingMethodArguments)
          Process dynamic expectations like any matcher starting with the word "not" is negated
 any registerMatcher(any name, any body)
          Registers a custom matcher on this Expectation object
 any toBe(any expected, [any message=''])
          Assert something is equal to each other, no case is required
 any toBeBetween(any min, any max, [any message=''])
          Assert that the passed in actual number or date is between the passed in min and max values
 any toBeCloseTo(any expected, any delta, [any datePart=''], [any message=''])
          Assert that the passed in actual number or date is expected to be close to it within +/- a passed delta and optional datepart
 any toBeEmpty([any message=''])
          Assert that a a given string, array, structure or query is empty
 any toBeFalse([any message=''])
          Assert something is false
 any toBeGT(any target, [any message=''])
          Assert that the actual value is greater than the target value
 any toBeGTE(any target, [any message=''])
          Assert that the actual value is greater than or equal the target value
 any toBeInstanceOf(string typeName, [any message=''])
          Assert that the actual object is of the expected instance type
 any toBeLT(any target, [any message=''])
          Assert that the actual value is less than the target value
 any toBeLTE(any target, [any message=''])
          Assert that the actual value is less than or equal the target value
 any toBeNull([any message=''])
          Assert something is null
 any toBeTrue([any message=''])
          Assert something is true
 any toBeTypeOf(string type, [any message=''])
          Assert the type of the incoming actual data, it uses the internal ColdFusion isValid() function behind the scenes
 any toBeWithCase(string expected, [any message=''])
          Assert strings are equal to each other with case
 any toHaveDeepKey(string key, [any message=''])
          Assert that a given key exists in the passed in struct by searching the entire nested structure
 any toHaveKey(string key, [any message=''])
          Assert that a given key exists in the passed in struct/object
 any toHaveLength(string length, [any message=''])
          Assert the size of a given string, array, structure or query
 any toInclude(any needle, [any message=''])
          Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity
 any toIncludeWithCase(any target, any needle, [any message=''])
          Assert that the given "needle" argument exists in the incoming string or array with case-sensitivity
 any toMatch(string regex, [any message=''])
          Assert that the actual data matches the incoming regular expression with no case sensitivity
 any toMatchWithCase(string actual, string regex, [any message=''])
          Assert that the actual data matches the incoming regular expression with case sensitivity
 any toThrow([any type=''], [any regex='.*'], [any message=''])
          Assert that the passed in function will throw an exception
 
Methods inherited from class WEB-INF.cftags.component
None
 

Constructor Detail

init

public init(any spec, any assertions, any mockBox)
Constructor

Parameters:
spec - The spec that this matcher belongs to.
assertions - The TestBox assertions object: coldbox.system.testing.Assertion
mockBox - A reference to MockBox
Property Detail

assert

any assert

Attributes:
default -
serializable - true
required - false

mockbox

any mockbox

Attributes:
default -
serializable - true
required - false

spec

any spec

Attributes:
default -
serializable - true
required - false

Method Detail

GETASSERT

public any GETASSERT()


GETMOCKBOX

public any GETMOCKBOX()


GETSPEC

public any GETSPEC()


SETASSERT

public Expectation SETASSERT(any assert)

Parameters:
assert

SETMOCKBOX

public Expectation SETMOCKBOX(any mockbox)

Parameters:
mockbox

SETSPEC

public Expectation SETSPEC(any spec)

Parameters:
spec

_not

public any _not()
Set the not bit to TRUE for this expectation.


fail

public any fail([any message=''])
Fail an assertion

Parameters:
message - The message to fail with.

onMissingMethod

public any onMissingMethod(any missingMethodName, any missingMethodArguments)
Process dynamic expectations like any matcher starting with the word "not" is negated

Parameters:
missingMethodName
missingMethodArguments

registerMatcher

public any registerMatcher(any name, any body)
Registers a custom matcher on this Expectation object

Parameters:
name - The name of the custom matcher
body - The body closure/udf representing this matcher.

toBe

public any toBe(any expected, [any message=''])
Assert something is equal to each other, no case is required

Parameters:
expected - The expected data
message - The message to send in the failure

toBeBetween

public any toBeBetween(any min, any max, [any message=''])
Assert that the passed in actual number or date is between the passed in min and max values

Parameters:
min - The expected min number or date
max - The expected max number or date
message - The message to send in the failure

toBeCloseTo

public any toBeCloseTo(any expected, any delta, [any datePart=''], [any message=''])
Assert that the passed in actual number or date is expected to be close to it within +/- a passed delta and optional datepart

Parameters:
expected - The expected number or date
delta - The +/- delta to range it
datePart - If passed in values are dates, then you can use the datepart to evaluate it
message - The message to send in the failure

toBeEmpty

public any toBeEmpty([any message=''])
Assert that a a given string, array, structure or query is empty

Parameters:
message - The message to send in the failure

toBeFalse

public any toBeFalse([any message=''])
Assert something is false

Parameters:
message - The message to send in the failure

toBeGT

public any toBeGT(any target, [any message=''])
Assert that the actual value is greater than the target value

Parameters:
target - The target value
message - The message to send in the failure

toBeGTE

public any toBeGTE(any target, [any message=''])
Assert that the actual value is greater than or equal the target value

Parameters:
target - The target value
message - The message to send in the failure

toBeInstanceOf

public any toBeInstanceOf(string typeName, [any message=''])
Assert that the actual object is of the expected instance type

Parameters:
typeName - The typename to check
message - The message to send in the failure

toBeLT

public any toBeLT(any target, [any message=''])
Assert that the actual value is less than the target value

Parameters:
target - The target value
message - The message to send in the failure

toBeLTE

public any toBeLTE(any target, [any message=''])
Assert that the actual value is less than or equal the target value

Parameters:
target - The target value
message - The message to send in the failure

toBeNull

public any toBeNull([any message=''])
Assert something is null

Parameters:
message - The message to send in the failure

toBeTrue

public any toBeTrue([any message=''])
Assert something is true

Parameters:
message - The message to send in the failure

toBeTypeOf

public any toBeTypeOf(string type, [any message=''])
Assert the type of the incoming actual data, it uses the internal ColdFusion isValid() function behind the scenes

Parameters:
type - The type to check, valid types are: array, binary, boolean, component, date, time, float, numeric, integer, query, string, struct, url, uuid
message - The message to send in the failure

toBeWithCase

public any toBeWithCase(string expected, [any message=''])
Assert strings are equal to each other with case.

Parameters:
expected - The expected data
message - The message to send in the failure

toHaveDeepKey

public any toHaveDeepKey(string key, [any message=''])
Assert that a given key exists in the passed in struct by searching the entire nested structure

Parameters:
key - The key to check for existence anywhere in the nested structure
message - The message to send in the failure

toHaveKey

public any toHaveKey(string key, [any message=''])
Assert that a given key exists in the passed in struct/object

Parameters:
key - The key to check for existence
message - The message to send in the failure

toHaveLength

public any toHaveLength(string length, [any message=''])
Assert the size of a given string, array, structure or query

Parameters:
length - The length to check
message - The message to send in the failure

toInclude

public any toInclude(any needle, [any message=''])
Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity

Parameters:
needle - The substring to find in a string or the value to find in an array
message - The message to send in the failure

toIncludeWithCase

public any toIncludeWithCase(any target, any needle, [any message=''])
Assert that the given "needle" argument exists in the incoming string or array with case-sensitivity

Parameters:
target
needle - The substring to find in a string or the value to find in an array
message - The message to send in the failure

toMatch

public any toMatch(string regex, [any message=''])
Assert that the actual data matches the incoming regular expression with no case sensitivity

Parameters:
regex - The regex to check with
message - The message to send in the failure

toMatchWithCase

public any toMatchWithCase(string actual, string regex, [any message=''])
Assert that the actual data matches the incoming regular expression with case sensitivity

Parameters:
actual - The actual data to check
regex - The regex to check with
message - The message to send in the failure

toThrow

public any toThrow([any type=''], [any regex='.*'], [any message=''])
Assert that the passed in function will throw an exception

Parameters:
type - Match this type with the exception thrown
regex - Match this regex against the message of the exception
message - The message to send in the failure

ColdBox Platform v3.8.0