jsonapi-resources-matchers 0.5.0 → 0.6.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: ffdc3c34e07d0eba98540f569af585f9a65ae833
4
- data.tar.gz: 76b8c6029107278b4f739182c42ac19c5c9426ef
3
+ metadata.gz: 03cf6ea8943f6a9191928662b6566341b283d0e1
4
+ data.tar.gz: 9e8246871c0fd14664e1b61eccd935f7b73fc31b
5
5
  SHA512:
6
- metadata.gz: 060978fd5389c6cf06d79085df92ed2e4a731d8407b2e12b9cf0bb41b726701240f3bed4ff1064f08ad6c92bc07023eb5fc08e5a336b192f852f790d70d938f3
7
- data.tar.gz: 4eb50049fd4a9e07d2d5fe75493e410208e0c5e40f2b96e764ef41cff058350947f586ac5592b0abb3eb8cfd34ee727457bec4b92d633bc620e13ccfd78b6591
6
+ metadata.gz: d29699e3bd8c0591c11a45255a42b369f7a037159438eb7f564b6829f8bf8e803a8aa9dca0ce8e808d74ec75fa174499a76754adaa18af65d264d7bf5fb07773
7
+ data.tar.gz: 6041e23d4a5442b4a2d90e0940806fd3e26269137ca95736ae11f162074c5f389c48e8ac070ee004c7c3fd60cc8f4032e6f3edf842acad8ac58e7391c3aa8c82
@@ -2,6 +2,10 @@
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
+ ## [0.6.0] - 2016-12-22
6
+ ### Added
7
+ - support for `have_sortable_field`
8
+
5
9
  ## [0.5.0] - 2016-11-24
6
10
  ### Added
7
11
  - support for `have_creatable_field` and `have_updatable_field`
@@ -2,6 +2,7 @@ require "jsonapi/resources/matchers/version"
2
2
  require "jsonapi/resources/matchers/have_attribute"
3
3
  require "jsonapi/resources/matchers/have_creatable_field"
4
4
  require "jsonapi/resources/matchers/have_updatable_field"
5
+ require "jsonapi/resources/matchers/have_sortable_field"
5
6
  require "jsonapi/resources/matchers/filter"
6
7
  require "jsonapi/resources/matchers/relationship"
7
8
  require "jsonapi/resources/matchers/have_model_name"
@@ -19,6 +20,10 @@ module JSONAPI
19
20
  HaveUpdatableField.new(name)
20
21
  end
21
22
 
23
+ def have_sortable_field(name)
24
+ HaveSortableField.new(name)
25
+ end
26
+
22
27
  def have_attribute(name)
23
28
  HaveAttribute.new(name)
24
29
  end
@@ -0,0 +1,34 @@
1
+ module JSONAPI
2
+ module Resources
3
+ module Matchers
4
+ class HaveSortableField
5
+
6
+ attr_accessor :name, :resource
7
+
8
+ def initialize(name)
9
+ self.name = name
10
+ end
11
+
12
+ def matches?(resource)
13
+ self.resource = resource
14
+ resource.class.sortable_fields(resource.context).include?(name)
15
+ end
16
+
17
+ def failure_message
18
+ resource_name = resource.class.name.demodulize
19
+ %Q(expected #{resource_name} to have sortable field `#{name}`)
20
+ end
21
+
22
+ def failure_message_when_negated
23
+ resource_name = resource.class.name.demodulize
24
+ %Q(expected #{resource_name} not to have sortable field `#{name}`)
25
+ end
26
+
27
+ def description
28
+ "have sortable field `#{name}`"
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,7 +1,7 @@
1
1
  module JSONAPI
2
2
  module Resources
3
3
  module Matchers
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.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.5.0
4
+ version: 0.6.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-11-24 00:00:00.000000000 Z
12
+ date: 2016-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-resources
@@ -108,6 +108,7 @@ files:
108
108
  - lib/jsonapi/resources/matchers/have_creatable_field.rb
109
109
  - lib/jsonapi/resources/matchers/have_model_name.rb
110
110
  - lib/jsonapi/resources/matchers/have_primary_key.rb
111
+ - lib/jsonapi/resources/matchers/have_sortable_field.rb
111
112
  - lib/jsonapi/resources/matchers/have_updatable_field.rb
112
113
  - lib/jsonapi/resources/matchers/integrations/rspec.rb
113
114
  - lib/jsonapi/resources/matchers/relationship.rb