Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Sequenced expectations can now be passed as non-callable values #16

Conversation

lukeraymonddowning
Copy link
Member

@lukeraymonddowning lukeraymonddowning commented Jun 14, 2021

Previously, values passed to the sequence method had to be callable closures.

This PR allows non-callable values to be passed to the sequence method. Each value will be wrapped in an expectation and toEqual will be called on it.

expect(['foo', 'bar', 'baz'])->sequence('foo', 'bar', 'baz');

Up for discussion is whether or not toBe would be better than toEqual here?

This PR also fixes the CI pipeline, which previously would always fail when installing dependencies!

@nunomaduro
Copy link
Member

nunomaduro commented Jun 14, 2021

Can you apply the same work to each()?

@lukeraymonddowning
Copy link
Member Author

Yes @nunomaduro 👍

@lukeraymonddowning
Copy link
Member Author

@nunomaduro not 100% sure this is what you mean, but I've updated so that if you provide more than 1 argument to the each method, it will defer to sequence instead.

expect([1, 2, 3])->each(fn($item) => $item->toBeInt()); // Works as normal

expect([1, 2, 3])->each(1, 2, 3); // Defers to sequence

If I've misunderstood just let me know

@lukeraymonddowning
Copy link
Member Author

Also, whilst we're on this point, should

expect([1, 2, 3])->each(fn($item) => $item->toBeInt())

instead return the normal expectation rather than the Each? Reason being that you're sort of indicating that you'd rather do the "each" expectation in a closure then carry on?

expect([1, 2, 3])
    ->each(fn($item) => $item->toBeInt())
    ->toBeArray(); // This would currently fail, but I wouldn't expect it to

@nunomaduro
Copy link
Member

@lukeraymonddowning Nevermind - What've said does not make sense.

@lukeraymonddowning
Copy link
Member Author

@nunomaduro reverted

@@ -4,6 +4,9 @@ on: ['push', 'pull_request']

jobs:
cs:
env:
Copy link
Member

Choose a reason for hiding this comment

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

Just a note, this could be added to a top level env key to remove the duplication, but not really necessary. 👍🏻

@nunomaduro
Copy link
Member

@lukeraymonddowning Can you please perform this pull request on the core?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants