These are chat archives for etorreborre/specs2

16th
May 2015
Rodolfo Hansen
@kryptt
May 16 2015 04:05
I have the following situation:
  implicit def fragmentsToProp(f: Fragments): Prop =
    f.executables.forall{ e =>  val r = e.execute; !(r.isError || r.isFailure) }
  "findByEmailQuery" ! forAll(genEmail, genUserState) { (e, us) => check(findByEmailQuery(e, us)) }
I'm trying to mix ScalaCheck with doobie-contrib-specs2 (which has a check(X): Fragments method, so I'm thinking I need to from Fragments back to Prop (from scalacheck)
Eric Torreborre
@etorreborre
May 16 2015 04:08
Which 'fragments' do you need to convert to a prop?
Rodolfo Hansen
@kryptt
May 16 2015 04:09
I believe what I did works, but loose out on the text generated by the doobie Framents (also where failed, etc)
I'm getting a org.specs2.specification.Fragments from the check method
Eric Torreborre
@etorreborre
May 16 2015 04:10
Not surprising, let me think about it
Eric Torreborre
@etorreborre
May 16 2015 04:18
Question: what are the fragments made of? Some text and one example? Several examples?
Do you want to display all the generated fragments or, more likely, only the failing ones?
I think the simple option is to take all the fragments and transform them into one failure message in your FragmentsToProp method but that's not fancy. I can try to find a better method
Rodolfo Hansen
@kryptt
May 16 2015 04:35
It has: some text and several examples
[info] + findByEmailQuery
[info] 
[info] Query0[User] defined at user-queries.scala:105
[info]   SELECT u.id, u.email, u.firstName, u.lastName, u.verified, u.state, u.passhash
[info]   FROM core.auth_tokens t INNER JOIN core.users u ON t.email = u.email
[info]   WHERE t.token = ? AND t.until >= now()
[info]   AND u.state = 'active'::core.user_state
[info] + SQL Compiles and Typechecks
[info] + P01 UUID  →  OTHER (uuid)
[info] + C01 id        BIGINT  (bigserial)  NOT NULL  →  Long
[info] + C02 email     VARCHAR (varchar)    NOT NULLString
[info] + C03 firstname VARCHAR (varchar)    NOT NULLString
....
It is impractical to repeat that block N times, it would however be nice to print it in a case where it failed.
Eric Torreborre
@etorreborre
May 16 2015 04:52
look at the gist here: https://gist.github.com/etorreborre/28dd7746c18b2cf752ce. It can be improved on the display side but at least all the information is there
[info] HelloWorldSpec
[info]
[info]  This is a specification to check the 'Hello world' string
[info]
[info]  The 'Hello world' string should
[error]    x use generators to create examples
[error]  Falsified after 0 passed tests.
[error]  > Labels of failing property:
[error]  x an int is equal to itself unless very large
[error]   ko (HelloWorldSpec.scala:28)
[error]  HelloWorldSpec
[error]  + a string is equal to itself unless very large
[error]
[error]  Total for specification HelloWorldSpec
[error]  Finished in 8 ms
[error]  2 examples, 1 failure, 0 error
[error]   (HelloWorldSpec.scala:41)
[error]  > ARG_0: -2147483648
[error]  > ARG_1: ""
[info]
[info] Total for specification HelloWorldSpec
[info] Finished in 379 ms
[info] 1 example, 1 failure, 0 error
[info]
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0
[error] Failed tests:
[error]     examples.HelloWorldSpec
Rodolfo Hansen
@kryptt
May 16 2015 04:55
nice!
let me see
Eric Torreborre
@etorreborre
May 16 2015 04:55
I just updated with some small tweaks, try revision 2
Rodolfo Hansen
@kryptt
May 16 2015 04:59
FYI: doobie is using specs 2.4
Eric Torreborre
@etorreborre
May 16 2015 05:01
maybe I should help migrate to 3.6 then
That reporting code has changed a lot since 2.4
I’ll have a look to see how hard it is to upgrade
Rodolfo Hansen
@kryptt
May 16 2015 05:04
Its a single file, should be fairly straight forward
(but I wanted to nail this down, before going the upgrade route)
:s
hmmm, let me try something out
Eric Torreborre
@etorreborre
May 16 2015 05:12
here you go: tpolecat/doobie#166
sorry I didn’t see that you wanted to do it. I’m on my phone now for the internet connection so the notifications aren’t great...
And I will probably stop here if i don’t want to crash my data bill for the month :-)
see you
Rodolfo Hansen
@kryptt
May 16 2015 05:22
awesome, thank! this was really helpful!