Evaluating forms in right side of =>

16 views
Skip to first unread message

David Smith

unread,
Mar 20, 2015, 8:30:29 AM3/20/15
to mi...@googlegroups.com
Sometimes it would be very nice to be able to have the right side of => be the result of it's evaluation.  E.g.

(let[user(new-user)]
   
(get-user (:id user)) => (dissoc user :password)

Otherwise I have to write something like

(let[user(new-user)
     result (dissoc user :password)]
   (get-user (:id user)) => result

IMO the first looks much better but it seems this is not possible.  Is there a way around this?  Is it something that could be included in future versions of Midje?

Although this example is somewhat basic, with slightly more complex tests, especially when using provided (which seems to have the same restriction), this can make things very messy...

Brian Marick

unread,
Mar 21, 2015, 11:00:38 AM3/21/15
to mi...@googlegroups.com


David Smith wrote:
> Sometimes it would be very nice to be able to have the right side of =>
> be the result of it's evaluation. E.g.

It does. For example:

user=> (fact
#_=> (let [user {:id 5}]
#_=> (+ 2 3) => (get user :id)))
true

If you add an example of a failure to a clone of
https://github.com/marick/sample-midje-project, I can look at it.

Reply all
Reply to author
Forward
0 new messages