[TestBox 1.0.0 Alpha] Problem with not() operator

Hello,

I’m building a spec to verify that a query will return at least one record.

This is the spec I’m using:

it("will return at least one record", function(){ expect(myObj.getRecords().RecordCount).not().toBe(0); });

When I run it, CF throws an exception:

Invalid construct: Either argument or name is missing.

When I remove the not operator the spec runs without throwing an exception.

I’m using CF 10,0,11,285437 with chf10000011.jar updater.

Thanks,

Matt

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.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

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.

Thanks,

Matt

Thanks for the feedback!

I entered this ticket: https://ortussolutions.atlassian.net/browse/TESTBOX-2

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

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().

Does the docs say anywhere about not()

The code

expect( actual ).not().toBe( 4 );

is actually straight out of the docs:

http://wiki.coldbox.org/wiki/TestBox.cfm#Not_operator

I assume the following code would work:

expect( actual )._not().toBe( 4 );

Is there another word or variation of “not” that we could do that won’t screw up the CFML parser?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Updated the docs for using the prefix.

Not sure if a concatenation is necessary anymore if we use the prefix

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

If .notToBe() is changed to .toNotBe()

Then instead of
“.toBe() or .notToBe()” - giggle…

it would be
“.toBe() or .toNotBe()” - not giggling…

:slight_smile: