If you match lists or maps or any other complex structures it's useful to see the difference between what is given and what expected. For example:
Map("a" -> 1, "b" -> 2, "c" -> 3) should equal Map("a" -> 1, "b" -> 5, "c" -> 3)
// ScalaTest output:
[info] Map("a" -> 1, "b" -> 2, "c" -> 3) did not equal Map("a" -> 1, "b" -> 5, "c" -> 3) (Test.scala)
[info] org.scalatest.exceptions.TestFailedException:
[info] ...
You would have to manually glance through both Maps to find the difference between them, the bigger your collection gets the harder it becomes.
In RSpec on the other hand you would get:
expect({a: 1, b: 2, c: 3}).to match({a: 1, b: 5, c: 3})
// RSpec output:
Failure/Error: it { expect({a: 1, b: 2, c: 3}).to match({a: 1, b: 5, c: 3})}
expected {:a=>1, :b=>2, :c=>3} to match {:a=>1, :b=>5, :c=>3}
Diff:
@@ -1,4 +1,4 @@
:a => 1,
-:b => 5,
+:b => 2,
:c => 3,
# ./spec/test_spec.rb:2:in `block (2 levels) in <top (required)>'
Is it possible to have something similar with ScalaTest?