jsonapi-resources-matchers 0.6.0 → 1.0.0

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
  SHA1:
3
- metadata.gz: 03cf6ea8943f6a9191928662b6566341b283d0e1
4
- data.tar.gz: 9e8246871c0fd14664e1b61eccd935f7b73fc31b
3
+ metadata.gz: 8d5eb7553b4ddb23d720be211d89683f3c4c88bc
4
+ data.tar.gz: d6a11affc10bff3b80af212f6ca782ea87aff4bd
5
5
  SHA512:
6
- metadata.gz: d29699e3bd8c0591c11a45255a42b369f7a037159438eb7f564b6829f8bf8e803a8aa9dca0ce8e808d74ec75fa174499a76754adaa18af65d264d7bf5fb07773
7
- data.tar.gz: 6041e23d4a5442b4a2d90e0940806fd3e26269137ca95736ae11f162074c5f389c48e8ac070ee004c7c3fd60cc8f4032e6f3edf842acad8ac58e7391c3aa8c82
6
+ metadata.gz: 46810d777d7bb4c400f86d5991111f0c42c890cb80e3948550838314022f645a1cd0402d41ff3dda885df3eb3dd8b14d9c578d01ddb6084890441255bd5af71c
7
+ data.tar.gz: 3fa6ff1723de7a92681b15559bcd0620a687c05c33b668a74d774e64201dbf5a561f91244cb7a8e398facbf7dfddb3e756ade38e7c403b72271ae909ec23f57e
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.5
3
+ - 2.4.0
4
+ sudo: false
@@ -2,6 +2,13 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [1.0.0] - 2016-02-28
6
+ ### Changed
7
+ - Require jsonapi-resources 0.9.0 and above
8
+
9
+ ### Fixed
10
+ - `have_attribute` and `have_one`, `have_many` matchers: give instructions to the developer when the primary key is not set
11
+
5
12
  ## [0.6.0] - 2016-12-22
6
13
  ### Added
7
14
  - support for `have_sortable_field`
data/Gemfile CHANGED
@@ -3,5 +3,5 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in jsonapi-resources-matchers.gemspec
4
4
  gemspec
5
5
 
6
- gem 'pry'
6
+ gem 'pry-byebug'
7
7
  gem 'sqlite3'
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "jsonapi-resources", ">= 0.6.0"
30
+ spec.add_dependency "jsonapi-resources", ">= 0.9.0"
31
31
 
32
32
  spec.add_development_dependency "bundler", "~> 1.10"
33
33
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,4 +1,5 @@
1
1
  require "jsonapi/resources/matchers/version"
2
+ require "jsonapi/resources/matchers/services/check_serialization"
2
3
  require "jsonapi/resources/matchers/have_attribute"
3
4
  require "jsonapi/resources/matchers/have_creatable_field"
4
5
  require "jsonapi/resources/matchers/have_updatable_field"
@@ -12,6 +12,8 @@ module JSONAPI
12
12
  def matches?(resource)
13
13
  self.resource = resource
14
14
 
15
+ CheckSerialization.(self.resource)
16
+
15
17
  resource_class = resource.class
16
18
 
17
19
  serialized_hash = JSONAPI::ResourceSerializer.new(resource_class).
@@ -25,11 +25,16 @@ module JSONAPI
25
25
  def matches?(resource)
26
26
  self.resource = resource
27
27
 
28
+ is_serializable? &&
28
29
  has_key_in_relationships? &&
29
30
  matches_class_name? &&
30
31
  matches_relation_name?
31
32
  end
32
33
 
34
+ def is_serializable?
35
+ CheckSerialization.(self.resource)
36
+ end
37
+
33
38
  def has_key_in_relationships?
34
39
  serialized_hash = JSONAPI::ResourceSerializer.new(resource.class).
35
40
  serialize_to_hash(resource).with_indifferent_access
@@ -0,0 +1,20 @@
1
+ module JSONAPI::Resources::Matchers
2
+ class CheckSerialization
3
+
4
+ MESSAGE = [
5
+ "`:primary_key` is nil.",
6
+ "In this scenario, jsonapi-resources does not",
7
+ "include the attributes in order for this matcher to work.",
8
+ "To get this working, initialize the model with a primary key set.",
9
+ ].join(" ")
10
+
11
+ def self.call(resource)
12
+ return true if resource.try(:id).present?
13
+ fail(
14
+ ArgumentError,
15
+ MESSAGE.gsub(":primary_key", resource.class._primary_key.to_s)
16
+ )
17
+ end
18
+
19
+ end
20
+ end
@@ -1,7 +1,7 @@
1
1
  module JSONAPI
2
2
  module Resources
3
3
  module Matchers
4
- VERSION = "0.6.0"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-resources-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - G5
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-22 00:00:00.000000000 Z
12
+ date: 2017-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-resources
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.6.0
20
+ version: 0.9.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.6.0
27
+ version: 0.9.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - lib/jsonapi/resources/matchers/have_updatable_field.rb
113
113
  - lib/jsonapi/resources/matchers/integrations/rspec.rb
114
114
  - lib/jsonapi/resources/matchers/relationship.rb
115
+ - lib/jsonapi/resources/matchers/services/check_serialization.rb
115
116
  - lib/jsonapi/resources/matchers/version.rb
116
117
  homepage: https://github.com/G5/jsonapi-resources-matchers
117
118
  licenses: