This repository has been archived by the owner on Jan 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
58 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,42 @@ | ||
# diff-x | ||
|
||
Pretty diffs for case classes. | ||
|
||
## Scalatest integration | ||
|
||
To use with scalatest, add the following dependency: | ||
|
||
```scala | ||
"com.softwaremill.diffx" %% "diffx-scalatest" % "0.1.0" | ||
``` | ||
|
||
Then, extend the `com.softwaremill.diffx.DiffMatcher` trait or `import com.softwaremill.diffx.DiffMatcher._`. | ||
You will then be able to use syntax such as: | ||
|
||
```scala | ||
left should matchTo(right) | ||
``` | ||
|
||
Giving you nice error messages, such as: | ||
|
||
![alt text](https://raw.githubusercontent.com/softwaremill/diffx/master/example.png) | ||
|
||
## Using directly | ||
|
||
Add the following dependency: | ||
|
||
```scala | ||
"com.softwaremill.diffx" %% "diffx-core" % "0.1.0" | ||
``` | ||
|
||
Then call: | ||
|
||
```scala | ||
import com.softwaremill.diffx.DiffFor | ||
implicitly[DiffFor[T]].diff(o1, o2) | ||
``` | ||
|
||
## Custom types | ||
|
||
If you'd like to implement custom matching logic for a custom type, create an implicit `DiffFor` instance for that | ||
type, and make sure it's in scope when creating `DiffFor` for the case class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.softwaremill.diffx | ||
|
||
trait DiffFor[T] { | ||
|
||
def diff(left: T, right: T): DiffResult | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ trait DiffMatcher extends DiffForInstances { | |
} | ||
|
||
} | ||
|
||
object DiffMatcher extends DiffMatcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters