These are chat archives for etorreborre/specs2

14th
Nov 2017
Wiem Zine El Abidine
@wi101
Nov 14 2017 09:03
Hello @etorreborre,
I would like to include a result of statement to the description of my spec.

This is my example:

sealed trait QueryField
case object maxElements extends QueryField { def apply() = this.toString }
case object fromElement extends QueryField { def apply() = this.toString }
override def is = s2"""
.....
You get an error InvalidQueryParameter if
        The ${maxElements()} <= 0 ${Negative.e1}
        The ${fromElement()} < 0  ${Negative.e2}
...

But by running the spec I've got:

...
 You get an error InvalidQueryParameter if
[info]         The maxElements* <= 0 TODO
[info]         The fromElement* < 0 TODO
...

What should I do to get this result?

...
 You get an error InvalidQueryParameter if
[info]         * The maxElements <= 0 TODO
[info]         * The fromElement < 0 TODO
...
Eric Torreborre
@etorreborre
Nov 14 2017 12:01
@asflierl right, the file separator might indeed be an issue
@wi101 I don't understand how you want to display the * where do the * come from?
Wiem Zine El Abidine
@wi101
Nov 14 2017 13:17
@etorreborre I have actually * because my example is def e1 = todo
it will be + or - after I implemented the examples that's why I want to organize the display
and normally * or + or - should at the beginning of the text.
Eric Torreborre
@etorreborre
Nov 14 2017 13:49

ok I get it now, sorry for being a bit slow on something I should know about :-).
This should work

You get an error InvalidQueryParameter if
        ${ s"The ${maxElements()} <= 0" ! Negative.e1 }

This creates an example with s"The ${maxElements()} <= 0 as a description and Negative.e1 as an execution. Then the outer $ injects it into the s2 interpolated string

Wiem Zine El Abidine
@wi101
Nov 14 2017 13:59
No problem :)
Thank you very much! it works