Naming question for new version of Mocketry

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Naming question for new version of Mocketry

Denis Kudriashov
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
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Max Leske

On 23 Mar 2016, at 10:48, Denis Kudriashov <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Denis Kudriashov

2016-03-23 11:02 GMT+01:00 Max Leske <[hidden email]>:
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
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Ben Coman
On Wed, Mar 23, 2016 at 6:31 PM, Denis Kudriashov <[hidden email]> wrote:
>
> 2016-03-23 11:02 GMT+01:00 Max Leske <[hidden email]>:
>>
>> 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

Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Denis Kudriashov

2016-03-23 12:38 GMT+01:00 Ben Coman <[hidden email]>:
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
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Ben Coman
On Wed, Mar 23, 2016 at 8:39 PM, Denis Kudriashov <[hidden email]> wrote:

>
> 2016-03-23 12:38 GMT+01:00 Ben Coman <[hidden email]>:
>>
>> 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

Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Denis Kudriashov

2016-03-23 14:05 GMT+01:00 Ben Coman <[hidden email]>:
[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

?
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Eliot Miranda-2
In reply to this post by Ben Coman


On Wed, Mar 23, 2016 at 6:05 AM, Ben Coman <[hidden email]> wrote:
On Wed, Mar 23, 2016 at 8:39 PM, Denis Kudriashov <[hidden email]> wrote:
>
> 2016-03-23 12:38 GMT+01:00 Ben Coman <[hidden email]>:
>>
>> 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
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Eliot Miranda-2
In reply to this post by Denis Kudriashov
Hi Denis,

On Wed, Mar 23, 2016 at 9:39 AM, Denis Kudriashov <[hidden email]> wrote:

2016-03-23 14:05 GMT+01:00 Ben Coman <[hidden email]>:
[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
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Denis Kudriashov

2016-03-23 19:39 GMT+01:00 Eliot Miranda <[hidden email]>:
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


Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Eliot Miranda-2


On Wed, Mar 23, 2016 at 12:04 PM, Denis Kudriashov <[hidden email]> wrote:

2016-03-23 19:39 GMT+01:00 Eliot Miranda <[hidden email]>:
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
Reply | Threaded
Open this post in threaded view
|

Re: Naming question for new version of Mocketry

Denis Kudriashov

2016-03-23 21:21 GMT+01:00 Eliot Miranda <[hidden email]>:
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.