Naming question for new version of Mocketry
Hello. I prepare new version of Mocketry with many new functions. And I have little question about some naming. It will be possible to verify (at the end of test) that particular message was happened. My first suggestion was: mock should receive someMessage But from English it not sounds like it should be occurred in past. So what correct and not long sentence can be used here? maybe: mock had received someMessage And same question for verification group of message sends (at the end of test): [mock someMessage. mock2 someMessage2] should occur [mock someMessage. mock2 someMessage2] should occurInSameOrder Does it sounds correct? What suggestions? Best regards, Denis
On 23 Mar 2016, at 10:48, Denis Kudriashov <dionisiydk@gmail.com> wrote:
Hello.
I prepare new version of Mocketry with many new functions. And I have little question about some naming.
It will be possible to verify (at the end of test) that particular message was happened. My first suggestion was:
mock should receive someMessage
But from English it not sounds like it should be occurred in past. So what correct and not long sentence can be used here? maybe:
mock had received someMessage
mock should haveReceived someMessage
And same question for verification group of message sends (at the end of test):
[mock someMessage. mock2 someMessage2] should occur [mock someMessage. mock2 someMessage2] should occurInSameOrder
[ mock someMessage. mock2 somMessage2 ] should have beenSent
Does it sounds correct? What suggestions?
Best regards, Denis
Cheers, Max
2016-03-23 11:02 GMT+01:00 Max Leske <maxleske@gmail.com>:
But from English it not sounds like it should be occurred in past. So what correct and not long sentence can be used here? maybe:
mock had received someMessage
mock should haveReceived someMessage
Thank's for suggestions. Thats idea from Marcus too. But it feels too long. But maybe. Now I actually already rename #receive to #haveReceived. But I hope for better sentence.
And same question for verification group of message sends (at the end of test):
[mock someMessage. mock2 someMessage2] should occur
[mock someMessage. mock2 someMessage2] should occurInSameOrder
[ mock someMessage. mock2 somMessage2 ] should have beenSent
It's long too. And I wish reduce number of separated words because it is not good practically. It raises more questions: how it is implemented, what the better name for intermediate object (result of have in that case) and others. At least your suggestion will be like [ mock someMessage. mock2 somMessage2 ] should haveBeenSent Another idea is to use #happen word: [ mock someMessage. mock2 somMessage2 ] should happen
On Wed, Mar 23, 2016 at 6:31 PM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2016-03-23 11:02 GMT+01:00 Max Leske <maxleske@gmail.com>:
But from English it not sounds like it should be occurred in past.
Normally thats my cue ;) but I don't have any great ideas.
So what correct and not long sentence can be used here? maybe:
mock had received someMessage
mock should haveReceived someMessage
Thank's for suggestions. Thats idea from Marcus too. But it feels too long. But maybe. Now I actually already rename #receive to #haveReceived. But I hope for better sentence.
And same question for verification group of message sends (at the end of test):
[mock someMessage. mock2 someMessage2] should occur
[mock someMessage. mock2 someMessage2] should occurInSameOrder
[ mock someMessage. mock2 somMessage2 ] should have beenSent
It's long too. And I wish reduce number of separated words because it is not good practically.
Maybe... [ mock someMessage. mock2 somMessage2 ] shouldve beenSent but maybe you don't want different #shouldXXX messages. cheers -ben
It raises more questions: how it is implemented, what the better name for intermediate object (result of have in that case) and others. At least your suggestion will be like [ mock someMessage. mock2 somMessage2 ] should haveBeenSent
Another idea is to use #happen word: [ mock someMessage. mock2 somMessage2 ] should happen
2016-03-23 12:38 GMT+01:00 Ben Coman <btc@openinworld.com>:
Maybe... [ mock someMessage. mock2 somMessage2 ] shouldve beenSent
but maybe you don't want different #shouldXXX messages.
Thank you too, Ben. And yes it will not follow other should expressions. But it would not be bad to use completely different word instead of #should
On Wed, Mar 23, 2016 at 8:39 PM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2016-03-23 12:38 GMT+01:00 Ben Coman <btc@openinworld.com>:
Maybe... [ mock someMessage. mock2 somMessage2 ] shouldve beenSent
but maybe you don't want different #shouldXXX messages.
Thank you too, Ben. And yes it will not follow other should expressions. But it would not be bad to use completely different word instead of #should
Okay, then perhaps... [mock someMessage. mock2 someMessage2] were sent [mock someMessage. mock2 someMessage2] were sentInOrder [mock someMessage. mock2 someMessage2] were done [mock someMessage. mock2 someMessage2] were doneInOrder but then do you also need singular #was for single items? [mock someMessage. mock2 someMessage2] expect done [mock someMessage. mock2 someMessage2] expect doneInOrder Expect squeezes in usage in both future and past tense... "I expect he'll arrive soon" "I expect he went home" cheers -ben
2016-03-23 14:05 GMT+01:00 Ben Coman <btc@openinworld.com>:
[mock someMessage. mock2 someMessage2] were done [mock someMessage. mock2 someMessage2] were doneInOrder
I really like this idea. Thank's. What about: [mock someMessage. mock2 someMessage2] should beDone [mock someMessage. mock2 someMessage2] should beDoneInOrder ?
Hi Denis, On Wed, Mar 23, 2016 at 9:39 AM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2016-03-23 14:05 GMT+01:00 Ben Coman <btc@openinworld.com>:
[mock someMessage. mock2 someMessage2] were done [mock someMessage. mock2 someMessage2] were doneInOrder
I really like this idea. Thank's.
What about:
[mock someMessage. mock2 someMessage2] should beDone [mock someMessage. mock2 someMessage2] should beDoneInOrder
?
This reads nicely. What is the class of the value answered by #should? What can you do with it? For example, assuming it is a record of the execution of the receiver, you could use [mock someMessage. mock2 someMessage2] executed completely [mock someMessage. mock2 someMessage2] executed completelyInOrder and then #executed is meaningful, whereas #should is merely a linguistic hack. And of course one could use #executes, but I think #executed is better; it has the sense of [mock someMessage. mock2 someMessage2] when executed, #executes completely :-) _,,,^..^,,,_ best, Eliot
2016-03-23 19:39 GMT+01:00 Eliot Miranda <eliot.miranda@gmail.com>:
This reads nicely. What is the class of the value answered by #should? What can you do with it?
It returns ShouldExpression instance which wraps receiver to execute following messages. And following messages are supposed to execute some assertions under receiver. For example it can be "1 should be: 2". Or in case with block: "[1/0] should raise: ZeroDivide" And for message sends verification I tried to find something similar.
For example, assuming it is a record of the execution of the receiver, you could use
[mock someMessage. mock2 someMessage2] executed completely [mock someMessage. mock2 someMessage2] executed completelyInOrder
and then #executed is meaningful, whereas #should is merely a linguistic hack.
And of course one could use #executes, but I think #executed is better; it has the sense of
[mock someMessage. mock2 someMessage2] when executed, #executes completely
On Wed, Mar 23, 2016 at 12:04 PM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2016-03-23 19:39 GMT+01:00 Eliot Miranda <eliot.miranda@gmail.com>:
This reads nicely. What is the class of the value answered by #should? What can you do with it?
It returns ShouldExpression instance which wraps receiver to execute following messages. And following messages are supposed to execute some assertions under receiver. For example it can be "1 should be: 2". Or in case with block: "[1/0] should raise: ZeroDivide"
Personally I would rename ShouldExpression to ExecutedBlock or ExecutedExpression, keep #should as nice syntactic sugar, but provide #executed as the standard way of creating ExecutedExpressions. After all this is useful for more than SUnit.
And for message sends verification I tried to find something similar.
For example, assuming it is a record of the execution of the receiver, you could use
[mock someMessage. mock2 someMessage2] executed completely [mock someMessage. mock2 someMessage2] executed completelyInOrder
and then #executed is meaningful, whereas #should is merely a linguistic hack.
And of course one could use #executes, but I think #executed is better; it has the sense of
[mock someMessage. mock2 someMessage2] when executed, #executes completely
_,,,^..^,,,_ best, Eliot
2016-03-23 21:21 GMT+01:00 Eliot Miranda <eliot.miranda@gmail.com>:
Personally I would rename ShouldExpression to ExecutedBlock or ExecutedExpression, keep #should as nice syntactic sugar, but provide #executed as the standard way of creating ExecutedExpressions. After all this is useful for more than SUnit.
Thank's for suggestion Eliot. I would think about it. Underhood should expressions are based on reusable components which has no relation to tests. It is first class specifications of object state. Should expression just creates particular instance of spec to validate receiver by it. So ShouldExpression is just syntax sugar helper class. It not implements any "real" behaviour.
On Wed, Mar 23, 2016 at 6:05 AM, Ben Coman <btc@openinworld.com> wrote:
On Wed, Mar 23, 2016 at 8:39 PM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2016-03-23 12:38 GMT+01:00 Ben Coman <btc@openinworld.com>:
Maybe... [ mock someMessage. mock2 somMessage2 ] shouldve beenSent
but maybe you don't want different #shouldXXX messages.
Thank you too, Ben. And yes it will not follow other should expressions.
But
it would not be bad to use completely different word instead of #should
Okay, then perhaps...
[mock someMessage. mock2 someMessage2] were sent [mock someMessage. mock2 someMessage2] were sentInOrder
[mock someMessage. mock2 someMessage2] were done [mock someMessage. mock2 someMessage2] were doneInOrder
but then do you also need singular #was for single items?
IMO use "was done/was doneInOrder". It is correct English to say "a compound action was performed". In any case it is the block that is evaluated, and that's a singular item. [mock someMessage. mock2 someMessage2] expect done
[mock someMessage. mock2 someMessage2] expect doneInOrder
Expect squeezes in usage in both future and past tense... "I expect he'll arrive soon" "I expect he went home"
cheers -ben
_,,,^..^,,,_ best, Eliot
participants (4)
-
Ben Coman -
Denis Kudriashov -
Eliot Miranda -
Max Leske