restspec 0.2.3 → 0.2.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 417a36622132a109cd6845d44bded2091db394e0
|
4
|
+
data.tar.gz: 8629b3f793e1065da423bd89a1fceeb680669c79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1693f46a758f3193c86a4024eedcdfff74b55a508e83da75a4936cf06b25995157c7a169b1a1d7a084aeaed1107e3f9f20565ccb2011ad874823d6e14ac6a950
|
7
|
+
data.tar.gz: 498eb609134cbb5173eac36f95a41d5085fe23d163ede0df6be16e43cf17adc6a4dae8f453bf9a595ebe7e3aec79b28471daddf38a13233df4e3fa5655e1babb
|
@@ -7,10 +7,10 @@ module Restspec::Schema::Types
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def example_for(attribute)
|
10
|
-
return sample_item.
|
10
|
+
return sample_item.try(id_property) if sample_item.present?
|
11
11
|
|
12
|
-
if create_response.code == 201 && create_response.body.try(
|
13
|
-
create_response.body.
|
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.
|
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
|
data/lib/restspec/version.rb
CHANGED