rspec-json_expectations 2.0.0 → 2.1.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad526ab43a8b702954d8248d6b1edeb62b10b559
|
4
|
+
data.tar.gz: 01aac3eeb128b3033ef51d03f7f1dde810f3824e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44aec293d47aa8e184a6ec335531c4bc92e3c31dfae6d404bd5b8e956032540f8ad2b3c8191e0eebad6eddd3576118f2f2b8700fcb535a8ce472f265b6b4ab65
|
7
|
+
data.tar.gz: 988b3ed14b8c35cc1fc9c58655ca3045765caac68a151bee15c73c0a85c3cf355252ef1f7ddf39a633de1fb5a581df5b26525bb324ae97d5ff5eea95b148c328
|
@@ -44,6 +44,30 @@ Feature: RSpec matcher support for include_json matcher
|
|
44
44
|
1 example, 0 failures
|
45
45
|
"""
|
46
46
|
|
47
|
+
Scenario: Expecting jsong string to include simple json using an rspec alias matcher
|
48
|
+
Given a file "spec/matcher_example_spec.rb" with:
|
49
|
+
"""ruby
|
50
|
+
require "spec_helper"
|
51
|
+
|
52
|
+
RSpec.describe "A json response" do
|
53
|
+
subject { '%{SIMPLE_JSON}' }
|
54
|
+
|
55
|
+
it "has basic info about user" do
|
56
|
+
expect(subject).to include_json(
|
57
|
+
id: a_kind_of(Numeric),
|
58
|
+
email: "john.smith@example.com",
|
59
|
+
name: "John",
|
60
|
+
score: (be > 30)
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
"""
|
65
|
+
When I run "rspec spec/matcher_example_spec.rb"
|
66
|
+
Then I see:
|
67
|
+
"""
|
68
|
+
1 example, 0 failures
|
69
|
+
"""
|
70
|
+
|
47
71
|
Scenario: Expecting json string to include simple json using an rspec matcher with failure
|
48
72
|
Given a file "spec/matcher_example_fail_spec.rb" with:
|
49
73
|
"""ruby
|
@@ -9,7 +9,7 @@ module RSpec
|
|
9
9
|
# json atom paths.
|
10
10
|
class JsonTraverser
|
11
11
|
HANDLED_BY_SIMPLE_VALUE_HANDLER = [String, Numeric, FalseClass, TrueClass, NilClass]
|
12
|
-
RSPECMATCHERS = [RSpec::Matchers::BuiltIn::BaseMatcher]
|
12
|
+
RSPECMATCHERS = [RSpec::Matchers::BuiltIn::BaseMatcher, RSpec::Matchers::AliasedMatcher]
|
13
13
|
SUPPORTED_VALUES = [Hash, Regexp, Array, Matchers::UnorderedArrayMatcher] +
|
14
14
|
HANDLED_BY_SIMPLE_VALUE_HANDLER + RSPECMATCHERS
|
15
15
|
|
@@ -114,7 +114,8 @@ module RSpec
|
|
114
114
|
|
115
115
|
def handle_rspec_matcher(errors, expected, actual, negate=false, prefix=[])
|
116
116
|
return nil unless defined?(RSpec::Matchers)
|
117
|
-
return nil unless expected.is_a?(RSpec::Matchers::BuiltIn::BaseMatcher)
|
117
|
+
return nil unless expected.is_a?(RSpec::Matchers::BuiltIn::BaseMatcher) ||
|
118
|
+
expected.is_a?(RSpec::Matchers::AliasedMatcher)
|
118
119
|
|
119
120
|
if conditionally_negate(!!expected.matches?(actual), negate)
|
120
121
|
true
|