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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 453f2d1cabd8d90513c4249388b3d2280d05bd8648d669d3f330685c7825bead
4
- data.tar.gz: 6bb89648163de76a82e4e0ea496c4ef71df7a595aec82239aca744172fb0f763
3
+ metadata.gz: '085d264d18f15d881bcf15ed6afc54914872902bd5b08737e5db7105d8c4de0b'
4
+ data.tar.gz: b4b3ef5093a2ebb42c030ba1776ebdb5babde215c684db5d48ba00e92a7509d1
5
5
  SHA512:
6
- metadata.gz: b46bad2d8208984f79ebe977563097ccf68121b646d9a4783427e86933566f8714dd840a50e4f7864705b684f2c48699c3ea0109d5642062494713222872c9d1
7
- data.tar.gz: 142399cd11e7dae1ab9ed9364a5a6609f7d8e68658455f037b5e032fd17ef7a5bffebd283a7bb163a85928e8ab9a5f5fdc7cfa32fc4121da7cdb4489f1ead778
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
- expect(json_response).to include_json(json_api
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[0].to_s.tr('_', '-') => fix_value_for_json(record.send(attr[0]))
73
+ hash.merge! attr.to_s.tr('_', '-') => fix_value_for_json(record.send(attr))
74
74
  end
75
75
  end
76
76
 
@@ -1,3 +1,3 @@
1
1
  module JsonApiTestHelpers
2
- VERSION = '1.1'
2
+ VERSION = '1.1.1'
3
3
  end
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: '1.1'
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-23 00:00:00.000000000 Z
11
+ date: 2019-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler