json_spec 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/json_spec.gemspec +1 -1
- data/lib/json_spec/matchers/include_json.rb +4 -2
- data/spec/json_spec/matchers/include_json_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98cdb5ce2f62a93c0ba56565fceea1f93a7d1d1e
|
4
|
+
data.tar.gz: 149b6060bc8514bcd6ad856e7ef748d622414f0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c6d9cad2a54c5485f142bc581a789d495542e7a4fee7ed385c6e1e147ec0a374486f673718e8dfeb1ad1feccb471ea09247c1500a8bb0907ac76d617d9be0d0
|
7
|
+
data.tar.gz: c4c4b16b051f2af4fe1e09151c6c6bbcd26c6f348db1ee3ccf06c784fbac9970708deec2b8386ce2ab63d3711621188d5d6a08f7a5a0a61b64f92d450f7932ee
|
data/json_spec.gemspec
CHANGED
@@ -12,6 +12,8 @@ module JsonSpec
|
|
12
12
|
def matches?(actual_json)
|
13
13
|
raise "Expected included JSON not provided" if @expected_json.nil?
|
14
14
|
|
15
|
+
@actual_json = actual_json
|
16
|
+
|
15
17
|
actual = parse_json(actual_json, @path)
|
16
18
|
expected = exclude_keys(parse_json(@expected_json))
|
17
19
|
case actual
|
@@ -43,12 +45,12 @@ module JsonSpec
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def failure_message
|
46
|
-
message_with_path("Expected
|
48
|
+
message_with_path("Expected #{@actual_json} to include #{@expected_json}")
|
47
49
|
end
|
48
50
|
alias :failure_message_for_should :failure_message
|
49
51
|
|
50
52
|
def failure_message_when_negated
|
51
|
-
message_with_path("Expected
|
53
|
+
message_with_path("Expected #{@actual_json} to not include #{@expected_json}")
|
52
54
|
end
|
53
55
|
alias :failure_message_for_should_not :failure_message_when_negated
|
54
56
|
|
@@ -71,6 +71,18 @@ describe JsonSpec::Matchers::IncludeJson do
|
|
71
71
|
matcher.description.should == %(include JSON at path "json/0")
|
72
72
|
end
|
73
73
|
|
74
|
+
it "provides a useful failure message for should" do
|
75
|
+
matcher = include_json(%([4,5,6]))
|
76
|
+
matcher.matches?(%([1,2,3]))
|
77
|
+
matcher.failure_message_for_should.should == "Expected [1,2,3] to include [4,5,6]"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "provides a useful failure message for should not" do
|
81
|
+
matcher = include_json(%(3))
|
82
|
+
matcher.matches?(%([1,2,3]))
|
83
|
+
matcher.failure_message_for_should_not.should == "Expected [1,2,3] to not include 3"
|
84
|
+
end
|
85
|
+
|
74
86
|
it "raises an error when not given expected JSON" do
|
75
87
|
expect{ %([{"id":1,"two":3}]).should include_json }.to raise_error
|
76
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Richert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|