Skip to content

Add more matchers #3

follesoe opened this Issue Jun 30, 2012 · 1 comment

1 participant


Currently we only have toBe, toEqual and toBeNil. We should probably add more matchers such as:

  • toHaveSlot to check if a object has a given slot
  • toContain to check if a List/Map contains an object
  • toBeTrue and toBeFalse to check boolean expressions
  • toThrow to check or exceptions

Adding the toThrow will greatly simplify our own testing of matchers, so it would make sense to implement this one first.

follesoe commented Jul 1, 2012

The toThrow matcher can be extended to take an expected parameter.

  • If the parameter is nil, then simply check if an exception is thrown (current implementation)
  • If the parameter is a Sequence, check that an exception is thrown, and that the error message matches.
  • If the parameter is a Exception object, check that the exception thrown is of same type, and same message as the expected exception.
@leavengood leavengood added a commit to leavengood/jasmineio that referenced this issue Oct 1, 2012
@leavengood leavengood Implement a more advanced toThrow. #3
Added new methods toThrowWithMessage and toThrowWithType which are
automatically called from toThrow based on the type of the expected
parameter. They could also be called explicitly.

Add associated specs as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.