check_please_rspec_matcher 0.3.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +13 -2
- data/check_please_rspec_matcher.gemspec +1 -1
- data/lib/check_please_rspec_matcher/matcher.rb +9 -9
- data/lib/check_please_rspec_matcher/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4805b31a16927ec62b4f5347d29cc40a2e2f79aa2e9ebfd6c5323cbf6805358d
|
4
|
+
data.tar.gz: d030a63536aa185a0513705b2a4a7367f3a788546e47cd9a6c630dcf1a012e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '049586b53390fd7d2f4ecfdc889cf3efa74cc8f9027e25ed5fcf130338f6da483a0bfc3d42423ce541dbb19b3b3a806b5123f7019feedc8ca14389f605a5ce54'
|
7
|
+
data.tar.gz: f5f218d15b7087a9bb84e394234489a9b9e0302cb85ec3629de1ee1c06a74a6496a35c5beba94d73cb40495c4096cb8404139f73924ebe9c4b668b630a2ef39f
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
check_please_rspec_matcher (0.
|
5
|
-
check_please (~> 0.
|
4
|
+
check_please_rspec_matcher (0.5.2)
|
5
|
+
check_please (~> 0.5.0)
|
6
6
|
rspec (~> 3.9)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
check_please (0.3
|
11
|
+
check_please (0.5.3)
|
12
12
|
table_print
|
13
13
|
diff-lcs (1.4.4)
|
14
14
|
rake (12.3.3)
|
data/README.md
CHANGED
@@ -5,6 +5,13 @@ structures parsed from them). Most of the heavy lifting is done by the
|
|
5
5
|
[check_please](https://github.com/RealGeeks/check_please) gem; this is merely
|
6
6
|
an RSpec wrapper that I didn't want to include in the main gem.
|
7
7
|
|
8
|
+
## See Also
|
9
|
+
|
10
|
+
If you'd like more control over the output formatting, and especially if you'd
|
11
|
+
like to provide custom logic for diffing your own classes, you might be better
|
12
|
+
served by the [super_diff](https://github.com/mcmire/super_diff) gem. Check it
|
13
|
+
out!
|
14
|
+
|
8
15
|
## Installation
|
9
16
|
|
10
17
|
Add this line to your application's Gemfile:
|
@@ -48,12 +55,16 @@ mismatch | /foo | 42 | 43
|
|
48
55
|
|
49
56
|
### Options
|
50
57
|
|
51
|
-
The `check_please` helper method
|
58
|
+
The `check_please` helper method accepts keyword arguments that correspond to
|
59
|
+
the flags defined in the CheckPlease gem. I haven't documented these yet, but
|
60
|
+
if you feel like reading some source code, search [this
|
61
|
+
file](https://github.com/RealGeeks/check_please/blob/main/lib/check_please.rb)
|
62
|
+
for `Flags.define`.
|
52
63
|
|
53
64
|
```ruby
|
54
65
|
reference = '{ "foo": 42 }'
|
55
66
|
candidate = '{ "foo": 43 }'
|
56
|
-
expect( candidate ).to check_please( reference,
|
67
|
+
expect( candidate ).to check_please( reference, format: :json )
|
57
68
|
```
|
58
69
|
|
59
70
|
Using `:json` as above will output the diffs in JSON instead of a table:
|
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_dependency "check_please", "~> 0.
|
28
|
+
spec.add_dependency "check_please", "~> 0.5.0" # NOTE: this should *usually* correspond with this gem's VERSION constant
|
29
29
|
spec.add_dependency "rspec", "~> 3.9"
|
30
30
|
end
|
@@ -3,15 +3,15 @@ require 'check_please'
|
|
3
3
|
module CheckPleaseRspecMatcher
|
4
4
|
|
5
5
|
module RSpecHelper
|
6
|
-
def check_please(expected,
|
7
|
-
CheckPleaseRspecMatcher::Matcher.new(expected,
|
6
|
+
def check_please(expected, flags = {})
|
7
|
+
::CheckPleaseRspecMatcher::Matcher.new(expected, flags)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
class Matcher
|
12
|
-
def initialize(expected,
|
12
|
+
def initialize(expected, flags = {})
|
13
13
|
@expected = expected
|
14
|
-
@
|
14
|
+
@flags = flags || {}
|
15
15
|
end
|
16
16
|
|
17
17
|
def matches?(actual)
|
@@ -20,20 +20,20 @@ module CheckPleaseRspecMatcher
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def failure_message
|
23
|
-
|
24
|
-
|
23
|
+
diff_text = ::CheckPlease::Printers.render(diffs, flags)
|
24
|
+
count = diffs.length == 1 ? "1 diff" : "#{diffs.length} diffs"
|
25
25
|
<<~EOF
|
26
|
-
Expected two JSON data structures to match, but found the following
|
26
|
+
Expected two JSON data structures to match, but found the following #{count}:
|
27
27
|
|
28
28
|
#{diff_text}
|
29
29
|
EOF
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
33
|
-
attr_reader :expected, :
|
33
|
+
attr_reader :expected, :flags, :actual
|
34
34
|
|
35
35
|
def diffs
|
36
|
-
@_diffs ||= ::CheckPlease.diff(
|
36
|
+
@_diffs ||= ::CheckPlease.diff(expected, actual, flags)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_please_rspec_matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Livingston-Gray
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: check_please
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|