I think the docs are either wrong or Expection.cfc is missing the not() method. Looking at the code, there is no method called “not” so I think you’re hitting the onMissingMethod which looks to see if the left three characters of the method name are “not”. So, I think even though the docs say you can do
expect( actual ).not().toBe( 4 );
I think the code actually only works for
expect( actual ).notToBe( 4 );
Now, that being said I’d like to suggest that Luis change that convention to put the word “not” after the “to” for readability so it would actually be like so:
expect( actual ).toNotBe( 4 );
I just think that reads better but it’s not a big deal.
And finally, back to what the docs say you can do-- I think if Luis simply renames the internal _not() function to not() it will work like documented.
I assume the “Invalid construct:Either argument or name is missing.” error is coming from line 79 of Expectation.cfc which is this:
var results = evaluate( “#arguments.missingMethodName#( argumentCollection=arguments.missingMethodArguments )” );
Since your method name is just “not”, that’s being stripped off and the arguments.missingMethodName variable is an empty string here. Some additional error checking in TestBox should help. Perhaps a check to ensure that the remaining string after the “not” is a valid method than can be executed since notFoobar() would also blow up.
I can confirm that when I replace: expect( actual ).not().toBe( 4 ) with: expect( actual ).notToBe( 4 ) the spec does not throw an exception.
I’ll go with this for the time being until the not() operator is sorted out. I understand this is an Alpha version (and a very good Alpha version at that!) and there might be a few wrinkles that need ironing.
The Not() operator does not exist, it has too many issues with the internal CFML engines, therefore I could not use it. What is on the docs is that you use the “not” prefix instead. So there is no concatenation not(). It is a prefix to any expectation: notToBe() notXXXXX().