[Rspec-devel] Adaptation of rpsec

David Chelimsky dchelimsky at gmail.com
Sat May 6 08:50:45 EDT 2006


On 5/6/06, Keith Hodges <Keith.Hodges at warwick.ac.uk> wrote:
> David Chelimsky wrote:
> > 3) Multiple expectations per expression
> > (expect(a).toBe(3).and(b).toBe(5))). I think this ends up more
> > confusing than just expressing the expectations separately.
> >  A key goal
> > should be consistency in expression and to make things more readable.
> > This would violate that consistency in my view. Also, what is the use
> > of or()? Why would you want to allow for any variation in the result?
> > That's just asking for bugs and headaches.
> >
> Oh? I included this on the basis that I would have thought that it would
> be more common in a specification to have a bit of flexibility
> specified. Such as "I expect this value to be a range of valid things".

Agreed that support for a range of valid things is desirable, but I've
usually seen this expressed like expect(a).toBeBetween(3).and(5) or
something like that. Using or() allows you to say
expect(a).toBe(3).or(7). That just seems odd to me. I can imagine it
to be more useful for non-numeric types:
expect(newHire).toBe(collegeGraduate).or(justReallySmart). My concern
would be misuse (i.e. 3 or 7). But now I sound like the people who
created things like static-typing in order to protect developers from
their inability to test their code :)



More information about the Rspec-devel mailing list