2
votes

I'm running the following test

Idea.findById(1).get.tags must equalTo(List[String]("internet, tecnología"))

and I'm getting the following error

[info] Idea.tags should
[error] x should retrieve a list of tag names for the idea
[error]    'internet, tecnología': anon is not equal to 'internet, tecnología': scala.collection.immutable.:: (IdeaTagSpec.scala:42)

this is the method I'm trying to test

lazy val tags: List[String] = {
  Tag.findByIdea(this).map(_.name).toList
}

I could solve it with this ugly hack

( Idea.findById(1).get.tags.toString 
    must equalTo(List[String]("internet, tecnología").toString)
)

But I'm sure there's a better way to do it...

-- EDIT --

sorry, it was a silly mistake on my part (It should habe been List("internet", "tecnologia") instead)

anyway the error message was quite misleading, that's why I'm leaving this question here...

1
Which specs2 version are you using? Can you please try with the latest one, 1.12.2? And if this doesn't work, post a fully executable example? Thanks. - Eric
I'm using the version 1.9 that comes bundled with play framework 2, 'll try to upgrade to 1.12.2 - opensas

1 Answers

1
votes

The situation will be improved with the next specs2 version. If you try out specs2-1.12.3-SNAPSHOT, you will get:

List("1, 2, 3") must_== List("1", "2", "3")

'List('1, 2, 3'): scala.collection.immutable.$colon$colon[java.lang.String]' 
  is not equal to 
'List('1', '2', '3'): scala.collection.immutable.$colon$colon[java.lang.String]'

The difference of quotes around each element should help, and if the types of the elements are different you'll get:

List(1, 2, 3) must_== List("1", "2", "3")

'List('1', '2', '3'): scala.collection.immutable.$colon$colon[java.lang.Integer]' 
  is not equal to 
'List('1', '2', '3'): scala.collection.immutable.$colon$colon[java.lang.String]'

And finally, for a "normal" case:

List(1, 2, 3) must_== List(3, 2, 1)

List(1, 2, 3) is not equal to List(3, 2, 1)