These are chat archives for etorreborre/specs2

17th
Apr 2017
Eric Torreborre
@etorreborre
Apr 17 2017 09:31
@tek nothing being worked on at the moment. Let me try to understand the issue. You have a case class CC and 2 instances of that class cc1 = CC(1, 2, ""), cc2 = CC(1, 2, "".asInstanceOf[String with ArbitraryString]) where one field's type is a subtype of the other?
Torsten Schmits
@tek
Apr 17 2017 09:36
I wanted to define something like a Diffable[String, String with ...] to allow case classes to differ in select fields…I'm doing a json test against an API where some fields contain large texts, which I don't want to include in the match value
Eric Torreborre
@etorreborre
Apr 17 2017 09:40
But what is your definition for CC? can you just define a custom Diffable instance for it ignoring the string field?
Torsten Schmits
@tek
Apr 17 2017 09:43
I guess. But there are multiple cases where I'd use this and they have quite a number of fields, so that would be a little more comfortable
Torsten Schmits
@tek
Apr 17 2017 09:49
so now I tried using a specific marker string to indicate that the field should be ignored, for which I test in my overridden String Diffable
Torsten Schmits
@tek
Apr 17 2017 09:55
and it works :)
though not if the field is nested in a List :worried:
Eric Torreborre
@etorreborre
Apr 17 2017 09:56
because the inferred type of List is List[String] and not List[String with Annotation]?
Torsten Schmits
@tek
Apr 17 2017 09:59
I don't use the tagged type, that cannot work. I have:
  val any = "--ArbitraryString--"

  implicit val Diffable_String_Arbitrary: Diffable[String] =
    new Diffable[String] {
      def diff(actual: String, expected: String): ComparisonResult = {
        if (expected == any) PrimitiveIdentical(actual)
        else Diffable.stringDiffable.diff(actual, expected)
      }
    }
and then I just insert any where I want to ignore the value
in the case of case class A(x: List[B]); case class B(y: String) it does not pick up the Diffable for y
though looking at SeqDiffable, I don't see why
Torsten Schmits
@tek
Apr 17 2017 10:34
ugh, duh
Torsten Schmits
@tek
Apr 17 2017 10:47
seems that none of the diffables in that file use the inner diffables for equivalence checks…should they?
Eric Torreborre
@etorreborre
Apr 17 2017 11:59
I haven't been reviewing all of this but yes I think they definitely should. Do you have time for another PR?
Torsten Schmits
@tek
Apr 17 2017 12:02
sure!
Eric Torreborre
@etorreborre
Apr 17 2017 12:03
Thanks! I'm trying to put some time aside to get a Scala.js build for specs2 and I feel I'm still very far from it
Torsten Schmits
@tek
Apr 17 2017 12:17
do you need specific tests for each of these?
Torsten Schmits
@tek
Apr 17 2017 17:04
after giving it a spin, it seems that I broke the None & None diffable
I'll better investigate
Torsten Schmits
@tek
Apr 17 2017 17:09
indeed. I left out the case of Nones to let it fall through to the OptionTypeDifferent case
better add a test
huh, there is one
ah.
that doesn't check (None: Option[A])
only the OptionNoneDiffable
Torsten Schmits
@tek
Apr 17 2017 17:22
yeah, it works now :D
Torsten Schmits
@tek
Apr 17 2017 18:27
@etorreborre btw, I have ported specs2 to python: https://github.com/tek/kallikrein
Eric Torreborre
@etorreborre
Apr 17 2017 21:05
@tek I did a quick release with your latest changes
Torsten Schmits
@tek
Apr 17 2017 21:05
thanks a lot!
Eric Torreborre
@etorreborre
Apr 17 2017 21:06
@tek just had a look at kallikrein, nice!
Torsten Schmits
@tek
Apr 17 2017 21:07
:)