Closed nathggns closed 11 years ago
Do you have an example?
So far example, on a user model, you added a test to make sure that a username doesn't already exist, that would have to be a closure.
You'd want it the rules array to be something like this.
[
'username' => [
'username_exists' => function($username) {
// ...
}
]
]
And if that fails, you'd want to be able to get the username_exists
as the name, as that's significant. The instance of closure, is not.
Right now, that just won't run as a test.
f68e1dacda6ce6abb5e9eafb35ce635bcdd79cdc implements this. What do you think @ClaudioAlbertin?
Been a while now. What do you think @ClaudioAlbertin?
Does it work without giving tests a name? If yes, it should be fine.
I wrote the code a while ago but I think so. Check the validator tests in this branch. — Nathaniel Higgins http://nath.is
On Sat, Jun 1, 2013 at 11:13 PM, Claudio Albertin notifications@github.com wrote:
Does it work without giving tests a name? If yes, it should be fine.
Reply to this email directly or view it on GitHub: https://github.com/Scaffold/Scaffold/issues/111#issuecomment-18797988
Should be fine then.
I'll merge it tomorrow then. — Nathaniel Higgins http://nath.is
On Sat, Jun 1, 2013 at 11:19 PM, Claudio Albertin notifications@github.com wrote:
Should be fine then.
Reply to this email directly or view it on GitHub: https://github.com/Scaffold/Scaffold/issues/111#issuecomment-18798083
It's possible to pass an array of tests for a value to the validator, but if you name them (passing a key), they just don't get called.
Instead, they should be named. This is especially useful for closure tests.
In the exception that is thrown, the name would be this passed name.