Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty objects in EqualKeys #50

Merged
merged 1 commit into from
Jan 4, 2016

Conversation

ruimarinho
Copy link
Member

Closes #34.

@ruimarinho ruimarinho added the enhancement New feature or request label Jan 3, 2016
@ruimarinho ruimarinho force-pushed the enhancement/handle-empty-objects branch from 4920d52 to 77374da Compare January 3, 2016 20:45
@ruimarinho ruimarinho force-pushed the enhancement/handle-empty-objects branch 2 times, most recently from f183494 to 697cc58 Compare January 3, 2016 22:36
@ruimarinho
Copy link
Member Author

ping @nunofgs

@@ -35,7 +35,7 @@ describe('EqualKeysAssert', () => {
});
});

it('should throw an error if an object does not have the expected keys', () => {
it('should throw an error if the object not have the expected keys', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not?

@nunofgs
Copy link
Contributor

nunofgs commented Jan 4, 2016

Hey guys, not trying to be difficult but I'm still having trouble with this concept. I personally dislike mixing "empty object" validation with key matching but I will of course capitulate if the intent is to follow the should.js implementation (as mentioned here).

Having said that, I believe the following should not throw an error:

// This throws an error.
new Assert().EqualKeys().validate({});

// Since this also does not throw an error.
({}).should.have.keys();

If you fix that issue, I have no further objections.

/cc @ricardogama, @ruimarinho

@nunofgs
Copy link
Contributor

nunofgs commented Jan 4, 2016

Also, regardless of the decision, should we also update the README with a description of the breaking change?

}
});

it('should allow setting no keys', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we setting here? WDYT of rewording to something along the lines of:

'should allow `keys` to be undefined'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ruimarinho ruimarinho force-pushed the enhancement/handle-empty-objects branch 3 times, most recently from 7169c49 to 74fd899 Compare January 4, 2016 21:56
@ruimarinho
Copy link
Member Author

@nunofgs I think the README is correct, but since the outcome might be different for a certain input value, I think publishing as 2.0.0 is enough.

I agree with your comment regarding new Assert().EqualKeys().validate({}); not throwing.

@nunofgs
Copy link
Contributor

nunofgs commented Jan 4, 2016

👍

@ricardogama
Copy link

LGTM

@ruimarinho ruimarinho force-pushed the enhancement/handle-empty-objects branch from 74fd899 to 9a33251 Compare January 4, 2016 22:20
ruimarinho added a commit that referenced this pull request Jan 4, 2016
@ruimarinho ruimarinho merged commit 73c2e40 into master Jan 4, 2016
@ruimarinho ruimarinho deleted the enhancement/handle-empty-objects branch January 4, 2016 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants