check_please_rspec_matcher 0.2.5 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- 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: 1fc284d1a6c957f037446c6dea6a5e9d38076aafce1b1e64db1f23bf7c536489
|
4
|
+
data.tar.gz: 793fa3a941bf7bb8082d2abc53199048c07a61176c6e750a02b4bd60da0eebce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11b1e79a81469c563650504a75fd31a3957bde72ec27feb4fadd757c0c59dc45d1038f0b9dbfa53ac8dbfa6c1d439b4d798bd8a8440f891e976c4a36934d9d86
|
7
|
+
data.tar.gz: 597a273f2c326d01ef35427805761334144afba1a8bcc0d0c59e42a5e14eccecb4847995c9f54e95d5a2fb223c7c5ee17c32d7aa8782e25edba18b45b5588bf4
|
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.1)
|
5
|
+
check_please (~> 0.4.1)
|
6
6
|
rspec (~> 3.9)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
check_please (0.
|
11
|
+
check_please (0.4.1)
|
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.4.1" # 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.1
|
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: 2020-11-
|
11
|
+
date: 2020-11-30 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.4.1
|
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.4.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|