assert_json 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjFmZDllNzY1MjM4YTJkZjg3ZjNkZmVmMGFhYTBhYTNkZGNiYzUwZg==
4
+ MzAxM2QzMGNiNzJiNDFhYTdkNWM0ZDZhNWRlYjIwMTMwZTUyN2Y4MQ==
5
5
  data.tar.gz: !binary |-
6
- NDRmZTM5YzYzMTEyNzYzODBiNjE2ZDEyN2M3MzE3MjEwMGRhM2I5NQ==
6
+ MjhlOGNmZGE0YTlmYzA0YTIyYmM0MTVlMTlkMDZkYmMxMzBiZDVjYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGVlNDRmNmU2MTlmNWIwNGViYmJkNjY5YTE5MjNiZTc3MjFkYzBhZWUyZGRl
10
- ZmM5YzQ1YjY1ZTZiNzJlNTZkNWQ3ZjMyZDQ0MjYxMjE0NDcxYmZmZjNlZjM1
11
- Yzg4NTJmNzM3N2MyNzQzNmNjMTE3MjU5Mjk3NGVkMjFhNWMwMzg=
9
+ NGNjMTA3MDc5N2VlNjJjZjA2ZDEyMjhmOTQ3YjZhOTdkZjVjMWNjMjlkZDYw
10
+ ZTMzYzkyNzgzNmRkOTU0NWZiMTViNTE0NGQzNzA3NGI5ODFiYWM0Y2VlYTAy
11
+ ZDUxMThjMjE3YzJhMjU2MGFjZjc1ZTNiMjdkOWIxZjMzMjU0ZDM=
12
12
  data.tar.gz: !binary |-
13
- YTJhYTZkOTEzNTlmNjFlOThkZGI4NWFhN2JiNjQ4YWFkMjBkZjVlMmI1OTZh
14
- NDhiMjNkNmQxYjIyMDc1MTEwODAwYjZiOWIyYzY5ZmRlMGJhMmE4YWQyMTFl
15
- NzM4NGU3M2QyMDYxYzE2NGY3ZDYxYzVlZjRmNWUyOGE2NDQwMjM=
13
+ YjlkZTk5NTQzOWU5MGQ3MjY1OGY4ZWNkMjkzMmJmZTg2YjY5Y2M3YjdiMzc2
14
+ ZTA3NzE3NjgxYjc5ZmEzMTYzZTNhODRjY2ZlODNhMWE1OTJjMmJkYmE2MmEw
15
+ ODRlYWZjYjU2OGZiMTk5NDk4MGFhNDUyYWRjN2FhYjA3YmI2MDI=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.1
4
+
5
+ * correctly match boolean and null values (thanks to [@pgaertig](https://github.com/pgaertig), see [issue 3](https://github.com/alto/assert_json/issues/3))
6
+
3
7
  ## 0.2.0
4
8
 
5
9
  * support selecting (and skipping) single items of an array (see [issue 2](https://github.com/alto/assert_json/issues/2))
@@ -45,7 +45,8 @@ module AssertJson
45
45
  case token
46
46
  when Hash
47
47
  raise_error("element #{arg} not found") unless token.keys.include?(arg)
48
- if second_arg = args.shift
48
+ unless args.empty?
49
+ second_arg = args.shift
49
50
  case second_arg
50
51
  when Regexp
51
52
  raise_error("element #{token[arg].inspect} does not match #{second_arg.inspect}") if second_arg !~ token[arg]
@@ -1,3 +1,3 @@
1
1
  module AssertJson
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -299,4 +299,49 @@ class AssertJsonNewDslTest < Test::Unit::TestCase
299
299
  end
300
300
  end
301
301
  end
302
+
303
+ def test_boolean
304
+ assert_json '{"key": true}' do
305
+ has 'key', true
306
+ end
307
+ assert_json '{"key": false}' do
308
+ has 'key', false
309
+ end
310
+ end
311
+
312
+ def test_boolean_crosscheck
313
+ assert_raises(MiniTest::Assertion) do
314
+ assert_json '{"key": false}' do
315
+ has 'key', true
316
+ end
317
+ end
318
+ assert_raises(MiniTest::Assertion) do
319
+ assert_json '{"key": true}' do
320
+ has 'key', false
321
+ end
322
+ end
323
+ end
324
+
325
+ def test_null
326
+ assert_json '{"key": null}' do
327
+ has 'key', nil
328
+ end
329
+ end
330
+
331
+ def test_not_null
332
+ assert_raises(MiniTest::Assertion) do
333
+ assert_json '{"key": 1}' do
334
+ has 'key', nil
335
+ end
336
+ end
337
+ end
338
+
339
+ def test_null_crosscheck
340
+ assert_raises(MiniTest::Assertion) do
341
+ assert_json '{"key": null}' do
342
+ has_not 'key'
343
+ end
344
+ end
345
+ end
346
+
302
347
  end
data/test/test_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'minitest'
2
3
  require 'test/unit'
3
4
  require 'active_support'
4
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Böttger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-22 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.1.11
80
+ rubygems_version: 2.2.2
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: A gem to test JSON strings.