match_json 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/match_json/matchers/include_json.rb +9 -0
- data/lib/match_json/version.rb +1 -1
- data/match_json.gemspec +1 -1
- data/spec/match_json/matchers_spec.rb +8 -0
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57bf78ba08a2206400b474522a4e5945ec306e9b
|
4
|
+
data.tar.gz: aa7e17daa7bab8fc1fd61e51fa694b67c3714ed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d759631412ea874063e35261a050b3652a0898b28c372a1f4669d266b852bbdca589384a87c5a66a8813b6304707a47a37aa40f09a773a0879af169748adaa96
|
7
|
+
data.tar.gz: 6c7fb7d11597b029a64b42e15b474b6281acb9c7e33b990bfe771f5ef45c146894ffe1cd3f9778f81672dfffe51569c5eee9bbcedb46cfbaeea984c0d658c4dc
|
@@ -35,6 +35,11 @@ module MatchJson
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def hash_included?(actual, expected, nested, raise_error)
|
38
|
+
if compared_different_types?(actual, expected)
|
39
|
+
@failure_message = %Q(Different types of compared elements:\n #{actual.class} for #{actual}\nand #{expected.class} for #{expected})
|
40
|
+
throw(:match, false)
|
41
|
+
end
|
42
|
+
|
38
43
|
expected.each do |key, value|
|
39
44
|
if (!equal_value?(actual[key], value, "#{nested} > #{key}", raise_error))
|
40
45
|
@failure_message = %Q("#{key}"=>#{value} was not found in\n #{actual})
|
@@ -93,6 +98,10 @@ module MatchJson
|
|
93
98
|
def regexp?(str)
|
94
99
|
!!(str =~ /\A\{re:.+\}\z/)
|
95
100
|
end
|
101
|
+
|
102
|
+
def compared_different_types?(actual, expected)
|
103
|
+
actual.class != expected.class
|
104
|
+
end
|
96
105
|
end
|
97
106
|
end
|
98
107
|
end
|
data/lib/match_json/version.rb
CHANGED
data/match_json.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "rspec"
|
21
|
+
spec.add_dependency "rspec", ">= 3.0", "< 4.0"
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
end
|
@@ -54,6 +54,14 @@ describe "include_json" do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
context 'when ckeck for inclusion of different types' do
|
58
|
+
it 'fails with clean message' do
|
59
|
+
expect {
|
60
|
+
expect(%Q([ { "one": 1 } ])).to include_json(%Q({ "one": 1 }))
|
61
|
+
}.to fail_with(%Q(Different types of compared elements:\n Array for [{"one"=>1}]\nand Hash for {"one"=>1}))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
57
65
|
context 'with pattern' do
|
58
66
|
it 'passes when value matches pattern' do
|
59
67
|
expect(%Q({"one": "test@exmaple.com"})).to include_json(%Q({"one": "{email}"}))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: match_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Gabriel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -17,14 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0'
|
20
|
+
version: '3.0'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '4.0'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0'
|
30
|
+
version: '3.0'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: bundler
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|