rspec-json_expectations 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c297902e9eca947b87a20ed364ba4b89df4999d
4
- data.tar.gz: cbcad8557c7b4e6b868952a9fbd7a095a502f412
3
+ metadata.gz: ad526ab43a8b702954d8248d6b1edeb62b10b559
4
+ data.tar.gz: 01aac3eeb128b3033ef51d03f7f1dde810f3824e
5
5
  SHA512:
6
- metadata.gz: df339e78a810a408a580c4a80cff1990fc03ddd5ecda91f7fd195750cf1a25bcb57bc5afc4f0435b2b1a9781617c408ba36da0f476b10cc7c059648226087191
7
- data.tar.gz: 69ebdd7402a814145b81567ab4e5ddcfd6d45b36680105d578470ca090c2e7af07ba4d1a5e8c2b196c273c067e158bb5f604a8bf14d551a3934654ce1fe1a123
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
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module JsonExpectations
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-json_expectations
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksii Fedorov