shoulda_render_json 0.0.2 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe7eea331763e3fd06b7087a3559d028d878ecb8
4
- data.tar.gz: 6c40596a0536786361d6851fbfcef87af00d1999
3
+ metadata.gz: ef78bccba9029da99a14deda88d8df69528c2c0e
4
+ data.tar.gz: 195b6cc8095378f6da8f1494e0281cab7e6b0bab
5
5
  SHA512:
6
- metadata.gz: 3e12b950d64609a53a34684d6dce5023d41a3746ed77edb339ed2ba051e0723ad3069556177ed0c6b5fa07c1081db6aec761ff08205b0ce9cc0c637101ac7c29
7
- data.tar.gz: 2f34610282d32c4883730e769af5785bc99acb58f006e7aaaf4c63566709bf41360f04cb42d1f2c61d36408b1258702d72281279be7292da2c697a40e55253c4
6
+ metadata.gz: b5892283c8f0049f8ba6c788ecea795973f3529b8f840ace30fb5ecab1278d59d7bdaf27f807da46170cd8c7cc9d24fbf96006327c9adf413e9124666208d293
7
+ data.tar.gz: 63acf880413fa8a69f0989f377c69f7b4523822275b3056ecb8cb404cfba139307c99b37b16bb034ad9f0c9c11a018626a4b0f2612de3656dc7eb971c720c322
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Shoulda RenderJson
1
+ # Shoulda RenderJson [![Code Climate](https://codeclimate.com/github/rsl/shoulda_render_json.png)](https://codeclimate.com/github/rsl/shoulda_render_json)
2
2
 
3
3
  Shoulda macros for making very basic assertions about JSON responses
4
4
 
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
  I'm going to presume you're already familiar with using Shoulda macros.
22
22
  The most basic assertion for `render_json` will be that your response's content-type is
23
23
  'application/json' (Rails' default JSON content-type) and that there is a root-level node
24
- named "foo" in the JSON.
24
+ named "foo" in the JSON.
25
25
 
26
26
  ```ruby
27
27
  should render_json('foo')
@@ -43,13 +43,13 @@ should render_json('foo', required: %w{bar baz})
43
43
  ```
44
44
 
45
45
  Sometimes, you may need to make assertions on Arrays inside JSON responses and not just Hash/Objects.
46
- I've got you covered there too.
46
+ I've got you covered there too.
47
47
 
48
48
  ```ruby
49
49
  should render_json('foo', type: Array)
50
50
  ```
51
51
 
52
- If you need to make assertions on the members of that Array, you can use the same `required` and
52
+ If you need to make assertions on the members of that Array, you can use the same `required` and
53
53
  `forbidden` options but be aware these assertions will be expected to be true for *every* member
54
54
  of the Array. If you've got members that violate this, you'll probably be better off writing custom
55
55
  assertions anyhow.
@@ -1,3 +1,3 @@
1
1
  module ShouldaRenderJson
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -21,6 +21,9 @@ class ShouldaRenderJsonObjectMatcher
21
21
  matches_root? &&
22
22
  has_required_keys? &&
23
23
  has_no_forbidden_keys?
24
+ rescue JSON::ParserError
25
+ set_failure_message "Response body was not a valid JSON string"
26
+ false
24
27
  end
25
28
 
26
29
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoulda_render_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - RSL
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-05 00:00:00.000000000 Z
11
+ date: 2014-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler