Synesso / instinct

Automatically exported from code.google.com/p/instinct

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add 'should' syntax

GoogleCodeExporter opened this issue · comments

What is the expected output? What do you see instead?

Instead of:

expect.that(value).equalTo(expected);

Some suggestions:

expect.that(value).shouldBeEqualTo(expected);
expect.that(value).shouldNotBeEqualTo(expected)



Original issue reported on code.google.com by nkp...@gmail.com on 4 Oct 2007 at 4:40

I think we will soon be walking a fine line between expressiveness and sheer
verbosity.  I totally agree that in this case we should have 'should'.  But 
something
we will need to consider.  I suppose there is no reason why we can have both the
'should' and non-'should' versions.

Original comment by cwmy...@gmail.com on 4 Oct 2007 at 9:13

I'm keen to see the expectations become more expressive. However, I don't 
believe
that 'should' is quite right. For example:
'I expect that it *should* rain today' doesn't sound right.
'I expect that it will rain today' is what we'd say.

So I suggest:
expect.that(result).willEqual(expected);
expect.that(result).willNotEqual(unexpected);

This is both concise and expressive.

I was just writing this and realised this is close to the pattern JMock uses! 
So it
must be right :-)

I'd also suggest that we don't make multiple versions at this stage. It will be
easier to keep it simple now, changing everything over to one 'right' way 
(whatever
we agree that is), and introduce alternatives later if we still feel there is a 
need.

Original comment by jeremywa...@gmail.com on 20 Nov 2007 at 5:20

Yeah I agree.  On reflection 'should' should not be added... I mean will not be
added.... I mean I expect that should will not be added.

or in code...

i.expect.that('should').willNotBe(added);

or something like that...  ;-)

Original comment by cwmy...@gmail.com on 20 Nov 2007 at 10:32

I've actually started doing this. I think there's now isEqualTo(), etc. There's 
no
problem adding more syntax, they all delegate to the "real" method anyway. For
example isOfType(), ofType(), instanceOf(), etc. all delegate to isInstanceOf().

As we're using Instinct, and I want a more expressive way, I've been adding 
these.
SOme other stuff we should do is to rationalise the checkers, so for example, 
arrays,
collections and strings all have size type checks (isOfSize(), hasSize(),
hasLength(), atLeastOfSize(), etc.).

Original comment by tomjad...@gmail.com on 21 Nov 2007 at 1:57

Rationalised the expectation checkers. These changes are in 0.1.6. Didn't add 
the
should syntax though.

Original comment by tomjad...@gmail.com on 18 Dec 2007 at 12:32

  • Changed state: Fixed