json_expressions 0.8.2 → 0.8.3
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 +7 -0
- data/CHANGELOG.md +8 -1
- data/README.md +14 -1
- data/lib/json_expressions/matcher.rb +2 -2
- data/lib/json_expressions/minitest.rb +14 -4
- data/lib/json_expressions/rspec/matchers/match_json_expression.rb +4 -1
- metadata +14 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 90c0f305959d6a5fcf0e47a839d8021724a0d790
|
4
|
+
data.tar.gz: 60da4f8a6b32c87aa62e077e3ef4669cd2e0b585
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7bb2a32202011bca76df60a933992b5136c58e3ca83db04b7c5cca21831c77d249b6d43140c44a02555a13235451bb1d14b1c2d30e18057c48bb3f814bb00739
|
7
|
+
data.tar.gz: cdce635eddc34a5f1027ae472ac726ddeda98c7238cf677916374b8e3bd3dff9d8907a6c4d374592e102532f0339c035e7bed0447c55f4972fffcb2d48ce0b9c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### v0.8.3 [view commit logs](https://github.com/chancancode/json_expressions/compare/0.8.2...0.8.3)
|
2
|
+
|
3
|
+
* Print more detailed error message when matching arrays (#26 from @Maxim-Filimonov)
|
4
|
+
* Add support for rspec 3+ (#24 from @george)
|
5
|
+
* Minitest 5 compat (#21 from @ffmike)
|
6
|
+
* Support using match_json_expression as an argument matcher for rspec. (#17 by @cupakromer)
|
7
|
+
|
1
8
|
### v0.8.2 [view commit logs](https://github.com/chancancode/json_expressions/compare/0.8.1...0.8.2)
|
2
9
|
|
3
10
|
* Bugfix: require 'rspec/core' instead of 'rspec' (#12 by @pda)
|
@@ -41,4 +48,4 @@
|
|
41
48
|
|
42
49
|
### v0.5.0
|
43
50
|
|
44
|
-
* Initial release
|
51
|
+
* Initial release
|
data/README.md
CHANGED
@@ -263,6 +263,19 @@ but not
|
|
263
263
|
{ "day": -1, "month": 13 }
|
264
264
|
```
|
265
265
|
|
266
|
+
This is also helpful for comparing Floats to a certain precision.
|
267
|
+
```ruby
|
268
|
+
{ pi: 3.141593 }
|
269
|
+
```
|
270
|
+
won't match
|
271
|
+
```json
|
272
|
+
{ "pi": 3.1415926536 }
|
273
|
+
```
|
274
|
+
But this will:
|
275
|
+
```ruby
|
276
|
+
{ pi: (3.141592..3.141593) }
|
277
|
+
```
|
278
|
+
|
266
279
|
### Capturing
|
267
280
|
|
268
281
|
Similar to how "captures" work in Regexp, you can capture the value of certain keys for later use:
|
@@ -397,4 +410,4 @@ Please use the [GitHub issue tracker](https://github.com/chancancode/json_expres
|
|
397
410
|
|
398
411
|
## License
|
399
412
|
|
400
|
-
This library is distributed under the MIT license. Please see the LICENSE file.
|
413
|
+
This library is distributed under the MIT license. Please see the LICENSE file.
|
@@ -124,11 +124,11 @@ module JsonExpressions
|
|
124
124
|
other = other.clone
|
125
125
|
|
126
126
|
matcher.all? do |v1|
|
127
|
-
if i = other.find_index { |v2| match_json(
|
127
|
+
if i = other.find_index { |v2| match_json(make_path(path, '*'), v1, v2) }
|
128
128
|
other.delete_at i
|
129
129
|
true
|
130
130
|
else
|
131
|
-
set_last_error path, "%path% does not contain
|
131
|
+
set_last_error path, "%path% does not contain a matching element for #{v1.inspect} - #{last_error}"
|
132
132
|
false
|
133
133
|
end
|
134
134
|
end
|
@@ -3,11 +3,21 @@ require 'minitest/spec'
|
|
3
3
|
require 'json_expressions'
|
4
4
|
require 'json_expressions/minitest/assertions'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
if defined?(MiniTest::VERSION) && (MiniTest::VERSION.to_i > 4)
|
7
|
+
class MiniTest::Test
|
8
|
+
WILDCARD_MATCHER = JsonExpressions::WILDCARD_MATCHER
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
def wildcard_matcher
|
11
|
+
::JsonExpressions::WILDCARD_MATCHER
|
12
|
+
end
|
13
|
+
end
|
14
|
+
else
|
15
|
+
class MiniTest::Unit::TestCase
|
16
|
+
WILDCARD_MATCHER = JsonExpressions::WILDCARD_MATCHER
|
17
|
+
|
18
|
+
def wildcard_matcher
|
19
|
+
::JsonExpressions::WILDCARD_MATCHER
|
20
|
+
end
|
11
21
|
end
|
12
22
|
end
|
13
23
|
|
@@ -17,14 +17,17 @@ module JsonExpressions
|
|
17
17
|
@target = (String === target) ? JSON.parse(target) : target
|
18
18
|
@expected =~ @target
|
19
19
|
end
|
20
|
+
alias_method :===, :matches?
|
20
21
|
|
21
22
|
def failure_message_for_should
|
22
23
|
"expected #{@target.inspect} to match JSON expression #{@expected.inspect}\n" + @expected.last_error
|
23
24
|
end
|
25
|
+
alias_method :failure_message, :failure_message_for_should
|
24
26
|
|
25
27
|
def failure_message_for_should_not
|
26
28
|
"expected #{@target.inspect} not to match JSON expression #{@expected.inspect}"
|
27
29
|
end
|
30
|
+
alias_method :failure_message_when_negated, :failure_message_for_should_not
|
28
31
|
|
29
32
|
def description
|
30
33
|
"should equal JSON expression #{@expected.inspect}"
|
@@ -36,4 +39,4 @@ module JsonExpressions
|
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
39
|
-
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_expressions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
5
|
-
prerelease:
|
4
|
+
version: 0.8.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Godfrey Chan
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-14 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: JSON matchmaking for all your API testing needs.
|
15
14
|
email:
|
@@ -18,41 +17,40 @@ executables: []
|
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- lib/json_expressions.rb
|
21
24
|
- lib/json_expressions/core_extensions.rb
|
22
25
|
- lib/json_expressions/matcher.rb
|
23
|
-
- lib/json_expressions/minitest/assertions.rb
|
24
26
|
- lib/json_expressions/minitest.rb
|
25
|
-
- lib/json_expressions/
|
26
|
-
- lib/json_expressions/rspec/matchers.rb
|
27
|
+
- lib/json_expressions/minitest/assertions.rb
|
27
28
|
- lib/json_expressions/rspec.rb
|
29
|
+
- lib/json_expressions/rspec/matchers.rb
|
30
|
+
- lib/json_expressions/rspec/matchers/match_json_expression.rb
|
28
31
|
- lib/json_expressions/test/unit/helpers.rb
|
29
32
|
- lib/json_expressions/testunit.rb
|
30
|
-
- lib/json_expressions.rb
|
31
|
-
- README.md
|
32
|
-
- CHANGELOG.md
|
33
|
-
- LICENSE
|
34
33
|
homepage: https://github.com/chancancode/json_expressions
|
35
34
|
licenses: []
|
35
|
+
metadata: {}
|
36
36
|
post_install_message:
|
37
37
|
rdoc_options: []
|
38
38
|
require_paths:
|
39
39
|
- lib
|
40
40
|
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
41
|
requirements:
|
43
|
-
- -
|
42
|
+
- - '>='
|
44
43
|
- !ruby/object:Gem::Version
|
45
44
|
version: '0'
|
46
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
46
|
requirements:
|
49
|
-
- -
|
47
|
+
- - '>='
|
50
48
|
- !ruby/object:Gem::Version
|
51
49
|
version: 1.3.6
|
52
50
|
requirements: []
|
53
51
|
rubyforge_project:
|
54
|
-
rubygems_version:
|
52
|
+
rubygems_version: 2.2.1
|
55
53
|
signing_key:
|
56
|
-
specification_version:
|
54
|
+
specification_version: 4
|
57
55
|
summary: JSON Expressions
|
58
56
|
test_files: []
|