Skip to content

Commit 65caef7

Browse files
committed
Update README
[ci skip]
1 parent 1548949 commit 65caef7

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

README.md

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,30 @@
77
[hound-badge]: https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg
88
[hound]: https://houndci.com
99

10-
SuperDiff is a Ruby gem that intelligently displays the differences between two
11-
data structures of any type.
10+
SuperDiff is a gem that hooks into RSpec to intelligently display the
11+
differences between two data structures of any type.
1212

1313
📢 **[See what's changed in the latest version (0.2.0)][changelog].**
1414

1515
[changelog]: CHANGELOG.md
1616

1717
## Introduction
1818

19-
The primary motivation behind this gem is to replace RSpec's built-in diffing
20-
capabilities. Sometimes, whenever you use a matcher such as `eq`, `match`,
21-
`include`, or `have_attributes`, you will get a diff of the two data structures
22-
you are trying to match against. This is really helpful for strings, but not so
23-
helpful for other, more "real world" kinds of values, such as arrays, hashes,
24-
and full-scale objects. The reason this doesn't work is because [all RSpec does
25-
is run your `expected` and `actual` values through Ruby's PrettyPrinter
26-
library][rspec-differ-fail] and then perform a diff of these strings.
19+
The primary motivation behind this gem is to vastly improve upon RSpec's
20+
built-in diffing capabilities.
21+
22+
Sometimes, whenever you use a matcher such as `eq`, `match`, `include`, or
23+
`have_attributes`, you will get a diff of the two data structures you are trying
24+
to match against. This is great if all you want to do is compare multi-line
25+
strings. But if you want to compare other, more "real world" kinds of values —
26+
nested data structures (arrays, hashes, and full-scale objects), such as what
27+
you might work with when developing API endpoints or testing methods that make
28+
database calls and return a set of model objects — then you are out of luck.
29+
Since [RSpec merely runs your `expected` and `actual` values through Ruby's
30+
PrettyPrinter library][rspec-differ-fail] and then performs a diff of these
31+
strings, the output it produces leaves much to be desired.
32+
33+
[rspec-differ-fail]: https://github.com/rspec/rspec-support/blob/c69a231d7369dd165ad7ce4742e1a2e21e3462b5/lib/rspec/support/differ.rb#L178
2734

2835
For instance, let's say you wanted to compare these two hashes:
2936

@@ -75,20 +82,16 @@ If, somewhere in a test, you were to say:
7582
expect(actual).to eq(expected)
7683
```
7784

78-
You would get output that looks like:
85+
You would get output that looks like this:
7986

8087
![Before super_diff](doc/before_super_diff.png)
8188

82-
Not great.
83-
84-
This library provides a diff engine that knows how to figure out the differences
85-
between any two data structures and display them in a sensible way. Using the
86-
example above, you'd get this instead:
89+
What this library does is to provide a diff engine that knows how to figure out
90+
the differences between any two data structures and display them in a sensible
91+
way. So, using the example above, you'd get this instead:
8792

8893
![After super_diff](doc/after_super_diff.png)
8994

90-
[rspec-differ-fail]: https://github.com/rspec/rspec-support/blob/c69a231d7369dd165ad7ce4742e1a2e21e3462b5/lib/rspec/support/differ.rb#L178
91-
9295
## Installation
9396

9497
Want to try out this gem for yourself? As with most development-related gems,
@@ -131,7 +134,7 @@ You're done!
131134
As capable as this library is, it doesn't know how to deal with every kind of
132135
object out there. You might find it necessary to instruct the gem on how to diff
133136
your object. To do this, you can use a configuration block. Simply add this to
134-
your test helper file (either `rails_helper` or `spec_helper`):
137+
your test helper file (`rails_helper` or `spec_helper`):
135138

136139
``` ruby
137140
SuperDiff::RSpec.configure do |config|
@@ -153,21 +156,21 @@ If you'd like to submit a PR instead, here's how to get started. First, fork
153156
this repo. Then, when you've cloned your fork, run:
154157

155158
```
156-
bundle install
159+
bin/setup
157160
```
158161

159162
This will install various dependencies. After this, you can run all of the
160-
tests:
163+
tests:
161164

162165
```
163166
bundle exec rake
164167
```
165168

166-
Or a single test:
169+
If you update one of the tests, you can run it like so:
167170

168171
```
169-
bundle exec rspec spec/acceptance/...
170-
bundle exec rspec spec/unit/...
172+
bin/rspec spec/integration/...
173+
bin/rspec spec/unit/...
171174
```
172175

173176
Finally, submit your PR and I'll take a look at it when I get a chance.

0 commit comments

Comments
 (0)