restspec 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97a565cd43b82dc19f31c53a7454abca3f95ab14
4
- data.tar.gz: 6b67ea1d2aad032245db04a43e78f4fb294570e3
3
+ metadata.gz: 417a36622132a109cd6845d44bded2091db394e0
4
+ data.tar.gz: 8629b3f793e1065da423bd89a1fceeb680669c79
5
5
  SHA512:
6
- metadata.gz: d5a94506ed34dc2aba3fb203a02c29939cf0506bbbd81cfba8ea8427706107df0a220f33540fc6edeb9d65e9e8595af29d7f194cd7e61a6a223be01325177715
7
- data.tar.gz: 5255e6c82d9dd4b85385d68a6c0f9ccb9cb7ece9edeab16234d7be28b89ad6fb833b7e7c4a3cbb2cb09c0c9e505e031f1518a96bb98356ac996d34ce3d687a8f
6
+ metadata.gz: 1693f46a758f3193c86a4024eedcdfff74b55a508e83da75a4936cf06b25995157c7a169b1a1d7a084aeaed1107e3f9f20565ccb2011ad874823d6e14ac6a950
7
+ data.tar.gz: 498eb609134cbb5173eac36f95a41d5085fe23d163ede0df6be16e43cf17adc6a4dae8f453bf9a595ebe7e3aec79b28471daddf38a13233df4e3fa5655e1babb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ~/dev/projects/ruby/restspec
3
3
  specs:
4
- restspec (0.2)
4
+ restspec (0.2.3)
5
5
  activesupport (~> 4.0)
6
6
  faker (~> 1.4)
7
7
  hashie (~> 3.3)
@@ -7,10 +7,10 @@ module Restspec::Schema::Types
7
7
  end
8
8
 
9
9
  def example_for(attribute)
10
- return sample_item.id if sample_item.present?
10
+ return sample_item.try(id_property) if sample_item.present?
11
11
 
12
- if create_response.code == 201 && create_response.body.try(:id).present?
13
- create_response.body.id
12
+ if create_response.code == 201 && create_response.body.try(id_property).present?
13
+ create_response.body.try(id_property)
14
14
  else
15
15
  hardcoded_fallback
16
16
  end
@@ -20,7 +20,7 @@ module Restspec::Schema::Types
20
20
 
21
21
  def valid?(attribute, value)
22
22
  return true unless perform_validation?
23
- item_ids.any? { |item| item.id == value }
23
+ item_ids.any? { |item| item.try(id_property) == value }
24
24
  end
25
25
 
26
26
  private
@@ -80,6 +80,10 @@ module Restspec::Schema::Types
80
80
  schema_options.fetch(:perform_validation, true)
81
81
  end
82
82
 
83
+ def id_property
84
+ example_options.fetch(:id) { schema_options.fetch(:id, :id) }
85
+ end
86
+
83
87
  def item_ids
84
88
  fetch_endpoint = get_index_endpoint
85
89
  fetch_endpoint.execute.body
@@ -1,3 +1,3 @@
1
1
  module Restspec
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag