json_api_test_helpers 1.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/json_api_test_helpers/response.rb +1 -1
- data/lib/json_api_test_helpers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '085d264d18f15d881bcf15ed6afc54914872902bd5b08737e5db7105d8c4de0b'
|
4
|
+
data.tar.gz: b4b3ef5093a2ebb42c030ba1776ebdb5babde215c684db5d48ba00e92a7509d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89ffbc28e38bba6dceebc8085c393c93b5f40276568334e4189a8ccb6fb1ff0e38fdd6ba50ca603563a6194da385b50996808ac2dd448bf8df724f2ae90d7934
|
7
|
+
data.tar.gz: b3b5eb41031be9c7215e2d2a21aec128a9d879a27524f8eb5e56d8382e69e1be34ca184f35d7865dd065c84ba664125b622e3956330f958e9d0b314ba519bfef
|
data/README.md
CHANGED
@@ -30,15 +30,16 @@ Methods:
|
|
30
30
|
| fix_value_for_json | `value` | Fix values which are usually used in Rails apps. `DateTime`, `ActiveSupport::TimeWithZone` to `iso8601`; `CarrierWave::Uploader::Serialization` to `serializable_hash`; everything else to Hash with replaced underscores `_` to minus `-` in attribute names |
|
31
31
|
| fix_comparing_types | `value` | Fix type value to easy compare. `DateTime`, `ActiveSupport::TimeWithZone` to `datetime` with UTC; `ActiveRecord::Point` to string `"#{value.x}, #{value.y}"`. |
|
32
32
|
| attributes_for_nested | `attributes`, `**associations` | Merge `attributes` with associations with JSON API format |
|
33
|
+
| json_api_params | `attributes` | Put params to `{ data: { attributes: your_params }}` object |
|
33
34
|
|
34
35
|
## Examples
|
35
36
|
|
36
37
|
```ruby
|
37
|
-
expect(json_response).to include_json(json_api_record(User.first))
|
38
|
+
expect(json_response).to include_json(json_api_record(User.first, [ :email, :another_attribute ]))
|
38
39
|
|
39
40
|
expect(json_response).to include_json(json_api_collection(User.all))
|
40
41
|
|
41
|
-
|
42
|
+
post 'some_post', params: json_api_params({ attribute1: :value1, attribute2: :value2 })
|
42
43
|
```
|
43
44
|
|
44
45
|
## Development
|
@@ -70,7 +70,7 @@ module JsonApiTestHelpers
|
|
70
70
|
|
71
71
|
def json_api_record_attributes(record, attributes)
|
72
72
|
attributes.reduce({}) do |hash, attr|
|
73
|
-
hash.merge! attr
|
73
|
+
hash.merge! attr.to_s.tr('_', '-') => fix_value_for_json(record.send(attr))
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_test_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|