jsonapi-rspec 0.0.3 → 0.0.4

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: b878b8a4ec8f73194ed8abe2b544e1495d19d0ccc5a430a5696993cf63c4f4a7
4
- data.tar.gz: 94be8756e49e6a50ce5723f9acd6982791b2a00cdfd7ad2c078189ec9190175a
3
+ metadata.gz: b47e58f3f6448c75638d51bf9b1e71158cf0ba27e9ad2ef3de757eefef637cff
4
+ data.tar.gz: cb6760bd5fbcfd5302f8b53cca011588fedbc591674859a08c4272b820297ba4
5
5
  SHA512:
6
- metadata.gz: 214b267455042c80a12476e976d7c4567dc21e8aa6239b29e97e6f55b2aab9285caefe39ab7af84c42090fd9792f97b2044b0a941277dc5cbf60b7ce95c284d2
7
- data.tar.gz: 6a2926acda88bb36be7455fabbfea98013c545032156b4375d2ab09b419bc23e67e26a03478c35a16cfeafa2140281e1053f1c2f3ed77bf6029a1fd40421c8f5
6
+ metadata.gz: bd3a469d0c1bdb3655f8d53b35a1dd4e65cb90d26ce7bd5dc8c3d9d8b391e352fa405fe76f9b49dc0943d263c6823abc6fa70904c3b7f4a420dc6ad53d62ea26
7
+ data.tar.gz: 8f2965c6f53ad2c2e92de9c550390eb964b07f3dfad58e3ded6e0527da5f61eb8aab126eeb758d34a53df36cf3e773a8b76ec40301c8022906950a2707bccfac
data/README.md CHANGED
@@ -36,7 +36,8 @@ Available matchers:
36
36
 
37
37
  * `expect(document['data']).to have_id('12')`
38
38
  * `expect(document['data']).to have_type('users')`
39
- * `expect(document['data']).to have_attributes(:name, :email)`
39
+ * `expect(document['data']).to have_jsonapi_attributes(:name, :email)`
40
+ * `expect(document['data']).to have_jsonapi_attributes(:name, :email, :country).exactly`
40
41
  * `expect(document['data']).to have_attribute(:name).with_value('Lucas')`
41
42
  * `expect(document['data']).to have_relationships(:posts, :comments)`
42
43
  * `expect(document['data']).to have_relationship(:posts).with_data([{ 'id' => '1', 'type' => 'posts' }])`
@@ -13,11 +13,18 @@ module JSONAPI
13
13
  end
14
14
  end
15
15
 
16
- ::RSpec::Matchers.define :have_attributes do |*attrs|
16
+ ::RSpec::Matchers.define :have_jsonapi_attributes do |*attrs|
17
17
  match do |actual|
18
18
  return false unless actual.key?('attributes')
19
19
 
20
- attrs.all? { |attr| actual['attributes'].key?(attr.to_s) }
20
+ counted = (attrs.size == actual['attributes'].size) if @exactly
21
+
22
+ (attrs.map(&:to_s) - actual['attributes'].keys).empty? &&
23
+ (counted == @exactly)
24
+ end
25
+
26
+ chain :exactly do
27
+ @exactly = true
21
28
  end
22
29
  end
23
30
  end
@@ -17,7 +17,8 @@ module JSONAPI
17
17
  if !(actual['relationships'] || {}).key?(rel.to_s)
18
18
  "expected #{actual} to have relationship #{rel}"
19
19
  else
20
- "expected #{actual['relationships'][rel.to_s]} to have data #{@data_val}"
20
+ "expected #{actual['relationships'][rel.to_s]} " \
21
+ "to have data #{@data_val}"
21
22
  end
22
23
  end
23
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Hosseini
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rake
56
+ name: rubocop-performance
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="