restspec 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +3 -3
- data/examples/store-api-tests/Gemfile.lock +3 -1
- data/examples/store-api-tests/api.md +127 -82
- data/examples/store-api-tests/spec/api/restspec/endpoints.rb +1 -1
- data/examples/store-api-tests/spec/api/restspec/schemas.rb +3 -3
- data/lib/restspec/endpoints/dsl.rb +2 -2
- data/lib/restspec/endpoints/has_schemas.rb +7 -1
- data/lib/restspec/runners/docs/templates/docs.md.erb +22 -6
- data/lib/restspec/schema/attribute.rb +10 -10
- data/lib/restspec/schema/dsl.rb +1 -1
- data/lib/restspec/schema/schema.rb +12 -0
- data/lib/restspec/schema/schema_example.rb +2 -6
- data/lib/restspec/version.rb +1 -1
- data/restspec.gemspec +1 -0
- data/spec/restspec/schema/attribute_spec.rb +1 -15
- data/spec/restspec/schema/dsl_spec.rb +0 -24
- data/spec/restspec/schema/schema_example_spec.rb +0 -10
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aee8d567251582d1e11bf1360b2539e2d8f9621c
|
4
|
+
data.tar.gz: 8746f5961969356e821728543118f4baa694b4aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 275c8062f82f7b72fa200ecae179b5ef668fc6bd09b0eaa4b57a2d4322e43ce8a2aae6a0eb8a323d84ba6864dc8593eae7772c6f3ac175925f92fb8ab7c97ae1
|
7
|
+
data.tar.gz: 8667413094c1599d61dbf84dd129a0a6b2cbd1abf9e0aeb7429f3052fbcbb2a7d6014b96f7effc7bbf479d7d04e780bb3a7579c1437a4918891b6e440405fe52
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
0.1
|
2
|
+
---
|
3
|
+
|
4
|
+
- Added `:for` option to `schema` methods on the endpoint definition. This allows to specify schemas for payloads, schemas for responses and schemas for whatever. See: https://github.com/platanus/restspec/issues/2.
|
5
|
+
- Added `no_schema` method to endpoint definitions. This is a subtask of https://github.com/platanus/restspec/issues/2..
|
6
|
+
|
7
|
+
0.2
|
8
|
+
---
|
9
|
+
- Fixed a problem with schema extensions (`:without`) not working due to the fact that endpoints saved schema clones that just were shallow clones. They still were sharing the internal attributes hash.
|
10
|
+
- Fixed `no_schema`. It was not working because the schema setting of the namepsace were happening after the `no_schema` call. From now, `all` definitions will happen before the specific schema definitions.
|
11
|
+
- Changed abilities of schemas related to endpoints to just be the same as the schema roles. It's preferrable to have attributes only for payload or only for responses than attributes only for examples or only for checks. This is the new feature of the release.
|
data/README.md
CHANGED
@@ -83,8 +83,8 @@ schema :product do
|
|
83
83
|
attribute :name, string
|
84
84
|
attribute :code, string
|
85
85
|
attribute :price, decimal | decimal_string
|
86
|
-
attribute :category_id, schema_id(:category), :for => [:
|
87
|
-
attribute :category, embedded_schema(:category), :for => [:
|
86
|
+
attribute :category_id, schema_id(:category), :for => [:payload]
|
87
|
+
attribute :category, embedded_schema(:category), :for => [:response]
|
88
88
|
end
|
89
89
|
|
90
90
|
schema :category do
|
@@ -186,7 +186,7 @@ Be sure to add your issue with a `bug` label or the `question` one.
|
|
186
186
|
|
187
187
|
## A note about SemVer
|
188
188
|
|
189
|
-
We are using SemVer from 0.0.4 onwards. Versions before 0.0.4 doesn't use Semver and they add some features (intended for MINOR releases, not for PATCH releases). With the addition of 0.
|
189
|
+
We are using SemVer from 0.0.4 onwards. Versions before 0.0.4 doesn't use Semver and they add some features (intended for MINOR releases, not for PATCH releases). With the addition of 0.1, we will be using a CHANGELOG.md file with the track of the commits that made their way to that version.
|
190
190
|
|
191
191
|
## Contribute
|
192
192
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ~/dev/projects/ruby/restspec
|
3
3
|
specs:
|
4
|
-
restspec (0.
|
4
|
+
restspec (0.1)
|
5
5
|
activesupport (~> 4.0)
|
6
6
|
faker (~> 1.4)
|
7
7
|
hashie (~> 3.3)
|
@@ -10,6 +10,7 @@ PATH
|
|
10
10
|
rspec (~> 3.0)
|
11
11
|
rspec-collection_matchers (~> 1.0)
|
12
12
|
rspec-its (~> 1.0)
|
13
|
+
ruby_deep_clone (~> 0.6)
|
13
14
|
thor (~> 0.19)
|
14
15
|
tilt (~> 2.0)
|
15
16
|
|
@@ -57,6 +58,7 @@ GEM
|
|
57
58
|
rspec-mocks (3.1.3)
|
58
59
|
rspec-support (~> 3.1.0)
|
59
60
|
rspec-support (3.1.2)
|
61
|
+
ruby_deep_clone (0.6.0)
|
60
62
|
slop (3.6.0)
|
61
63
|
thor (0.19.1)
|
62
64
|
thread_safe (0.3.4)
|
@@ -5,140 +5,185 @@
|
|
5
5
|
|
6
6
|
### Create [POST /products]
|
7
7
|
|
8
|
-
|
8
|
+
#### Payload
|
9
9
|
|
10
|
+
The payload is an instance of the **product** schema.
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
|
13
|
+
```json
|
14
|
+
{
|
15
|
+
"name": "consequatur",
|
16
|
+
"code": "corporis",
|
17
|
+
"price": 86.56,
|
18
|
+
"category_id": "5"
|
19
|
+
}
|
20
|
+
```
|
21
|
+
|
22
|
+
|
23
|
+
#### Response
|
24
|
+
Returns schema **product**
|
25
|
+
|
26
|
+
|
27
|
+
```json
|
28
|
+
{
|
29
|
+
"created_at": "2014-12-08T20:04:00-05:00",
|
30
|
+
"updated_at": "2014-12-02T21:02:47-05:00",
|
31
|
+
"name": "ut",
|
32
|
+
"code": "nobis",
|
33
|
+
"price": 13.52,
|
34
|
+
"category_id": "1",
|
35
|
+
"category": {
|
36
|
+
"name": "delectus"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
```
|
20
40
|
|
21
41
|
### Index [GET /products]
|
22
42
|
|
23
|
-
|
43
|
+
|
44
|
+
#### Response
|
45
|
+
Returns schema **product**
|
24
46
|
|
25
47
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
48
|
+
```json
|
49
|
+
{
|
50
|
+
"created_at": "2014-12-27T12:23:04-05:00",
|
51
|
+
"updated_at": "2014-12-04T23:20:43-05:00",
|
52
|
+
"name": "voluptatem",
|
53
|
+
"code": "facilis",
|
54
|
+
"price": 41.47,
|
55
|
+
"category_id": "8"
|
56
|
+
}
|
57
|
+
```
|
35
58
|
|
36
59
|
### Show [GET /products/:id]
|
37
60
|
|
38
|
-
Returns schema **product**
|
39
61
|
|
62
|
+
#### Response
|
63
|
+
Returns schema **product**
|
40
64
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
65
|
+
|
66
|
+
```json
|
67
|
+
{
|
68
|
+
"created_at": "2014-11-28T20:21:40-05:00",
|
69
|
+
"updated_at": "2014-12-28T08:10:27-05:00",
|
70
|
+
"name": "quasi",
|
71
|
+
"code": "rerum",
|
72
|
+
"price": 39.48,
|
73
|
+
"category_id": "0",
|
74
|
+
"category": {
|
75
|
+
"name": "saepe"
|
76
|
+
}
|
77
|
+
}
|
78
|
+
```
|
50
79
|
|
51
80
|
### Update [PUT /products/:id]
|
52
81
|
|
53
|
-
Returns schema **product**
|
54
82
|
|
83
|
+
#### Response
|
84
|
+
Returns schema **product**
|
55
85
|
|
56
|
-
| Attribute | Type | Example |
|
57
|
-
|-------------|:--------------------------:|---------------:|
|
58
|
-
| created_at | date_time | 2014-12-11T19:55:48-05:00 |
|
59
|
-
| updated_at | date_time | 2014-12-01T18:33:17-05:00 |
|
60
|
-
| name | string | possimus |
|
61
|
-
| code | string | omnis |
|
62
|
-
| price | decimal | 13.37 |
|
63
|
-
| category_id | schema_id | 51 |
|
64
|
-
| category | embedded_schema | {:name=>"tempora"} |
|
65
86
|
|
66
|
-
|
87
|
+
```json
|
88
|
+
{
|
89
|
+
"created_at": "2014-12-27T02:32:32-05:00",
|
90
|
+
"updated_at": "2014-12-05T22:31:32-05:00",
|
91
|
+
"name": "iure",
|
92
|
+
"code": "autem",
|
93
|
+
"price": 47.17,
|
94
|
+
"category_id": "1",
|
95
|
+
"category": {
|
96
|
+
"name": "ut"
|
97
|
+
}
|
98
|
+
}
|
99
|
+
```
|
67
100
|
|
68
|
-
|
101
|
+
### Destroy [DELETE /products/:id]
|
69
102
|
|
70
103
|
|
71
|
-
|
72
|
-
|
73
|
-
| created_at | date_time | 2014-12-17T17:29:46-05:00 |
|
74
|
-
| updated_at | date_time | 2014-12-22T08:20:22-05:00 |
|
75
|
-
| name | string | quos |
|
76
|
-
| code | string | aut |
|
77
|
-
| price | decimal | 32.84 |
|
78
|
-
| category_id | schema_id | 51 |
|
79
|
-
| category | embedded_schema | {:name=>"saepe"} |
|
104
|
+
#### Response
|
105
|
+
The response is empty.
|
80
106
|
|
81
107
|
|
82
108
|
## Categories
|
83
109
|
|
84
110
|
### Create [POST /categories]
|
85
111
|
|
86
|
-
|
112
|
+
|
113
|
+
#### Response
|
114
|
+
Returns schema **category**
|
87
115
|
|
88
116
|
|
89
|
-
|
90
|
-
|
91
|
-
|
117
|
+
```json
|
118
|
+
{
|
119
|
+
"name": "quaerat"
|
120
|
+
}
|
121
|
+
```
|
92
122
|
|
93
123
|
### Index [GET /categories]
|
94
124
|
|
95
|
-
Returns schema **category**
|
96
125
|
|
126
|
+
#### Response
|
127
|
+
Returns schema **category**
|
97
128
|
|
98
|
-
|
99
|
-
|
100
|
-
|
129
|
+
|
130
|
+
```json
|
131
|
+
{
|
132
|
+
"name": "amet"
|
133
|
+
}
|
134
|
+
```
|
101
135
|
|
102
136
|
### Show [GET /categories/:id]
|
103
137
|
|
104
|
-
|
138
|
+
|
139
|
+
#### Response
|
140
|
+
Returns schema **category**
|
105
141
|
|
106
142
|
|
107
|
-
|
108
|
-
|
109
|
-
|
143
|
+
```json
|
144
|
+
{
|
145
|
+
"name": "consequatur"
|
146
|
+
}
|
147
|
+
```
|
110
148
|
|
111
149
|
### Update [PUT /categories/:id]
|
112
150
|
|
113
|
-
Returns schema **category**
|
114
151
|
|
152
|
+
#### Response
|
153
|
+
Returns schema **category**
|
115
154
|
|
116
|
-
| Attribute | Type | Example |
|
117
|
-
|-------------|:--------------------------:|---------------:|
|
118
|
-
| name | string | vel |
|
119
155
|
|
120
|
-
|
156
|
+
```json
|
157
|
+
{
|
158
|
+
"name": "voluptatem"
|
159
|
+
}
|
160
|
+
```
|
121
161
|
|
122
|
-
|
162
|
+
### Destroy [DELETE /categories/:id]
|
123
163
|
|
124
164
|
|
125
|
-
|
126
|
-
|
127
|
-
| name | string | rerum |
|
165
|
+
#### Response
|
166
|
+
The response is empty.
|
128
167
|
|
129
168
|
### Products [GET /categories/:id/products]
|
130
169
|
|
131
|
-
|
170
|
+
|
171
|
+
#### Response
|
172
|
+
Returns schema **product**
|
132
173
|
|
133
174
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
175
|
+
```json
|
176
|
+
{
|
177
|
+
"created_at": "2014-12-13T00:42:13-05:00",
|
178
|
+
"updated_at": "2014-12-12T18:31:59-05:00",
|
179
|
+
"name": "labore",
|
180
|
+
"code": "exercitationem",
|
181
|
+
"price": 15.84,
|
182
|
+
"category_id": "0",
|
183
|
+
"category": {
|
184
|
+
"name": "incidunt"
|
185
|
+
}
|
186
|
+
}
|
187
|
+
```
|
143
188
|
|
144
189
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
mixin :timestamps do
|
2
|
-
attribute :created_at, datetime, :for => [:
|
3
|
-
attribute :updated_at, datetime, :for => [:
|
2
|
+
attribute :created_at, datetime, :for => [:response]
|
3
|
+
attribute :updated_at, datetime, :for => [:response]
|
4
4
|
end
|
5
5
|
|
6
6
|
schema :product do
|
@@ -10,7 +10,7 @@ schema :product do
|
|
10
10
|
attribute :code, string
|
11
11
|
attribute :price, decimal | decimal_string
|
12
12
|
attribute :category_id, schema_id(:category)
|
13
|
-
attribute :category, embedded_schema(:category), :for => [:
|
13
|
+
attribute :category, embedded_schema(:category), :for => [:response]
|
14
14
|
end
|
15
15
|
|
16
16
|
schema :category do
|
@@ -83,12 +83,12 @@ module Restspec
|
|
83
83
|
endpoint_dsl = EndpointDSL.new(endpoint)
|
84
84
|
namespace.add_endpoint(endpoint)
|
85
85
|
|
86
|
-
endpoint_dsl.instance_eval(&block)
|
87
|
-
|
88
86
|
endpoint_config_blocks.each do |config_block|
|
89
87
|
endpoint_dsl.instance_eval(&config_block)
|
90
88
|
end
|
91
89
|
|
90
|
+
endpoint_dsl.instance_eval(&block)
|
91
|
+
|
92
92
|
Restspec::EndpointStore.store(endpoint)
|
93
93
|
end
|
94
94
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/concern'
|
2
|
+
require 'deep_clone'
|
2
3
|
|
3
4
|
module Restspec
|
4
5
|
module Endpoints
|
@@ -16,7 +17,12 @@ module Restspec
|
|
16
17
|
roles = options.delete(:for) || DEFAULT_ROLES
|
17
18
|
|
18
19
|
roles.each do |role|
|
19
|
-
|
20
|
+
schema_found = Restspec::SchemaStore.fetch(schema_name)
|
21
|
+
|
22
|
+
schema_roles[role] = DeepClone.clone(schema_found)
|
23
|
+
schema_roles[role].intention = role
|
24
|
+
schema_roles[role].original_schema = schema_found
|
25
|
+
|
20
26
|
if options.any?
|
21
27
|
schema_roles[role].extend_with(options)
|
22
28
|
end
|
@@ -7,14 +7,30 @@
|
|
7
7
|
<% namespace.all_endpoints.each do |endpoint| %>
|
8
8
|
### <%= endpoint.name.capitalize %> [<%= endpoint.method.upcase %> <%= endpoint.full_path %>]
|
9
9
|
|
10
|
-
|
10
|
+
<% if payload_schema = endpoint.schema_for(:payload) %>
|
11
|
+
#### Payload
|
11
12
|
|
12
|
-
|
13
|
+
The payload is an instance of the **<%= payload_schema.name %>** schema.
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
<% sample = Restspec::Schema::SchemaExample.new(payload_schema).value %>
|
16
|
+
|
17
|
+
```json
|
18
|
+
<%= JSON.pretty_generate(sample).gsub(/^/, ' ') %>
|
19
|
+
```
|
20
|
+
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
#### Response
|
24
|
+
<% if response_schema = endpoint.schema_for(:response) %>
|
25
|
+
Returns schema **<%= response_schema.name %>**
|
26
|
+
|
27
|
+
<% sample = Restspec::Schema::SchemaExample.new(response_schema).value %>
|
28
|
+
|
29
|
+
```json
|
30
|
+
<%= JSON.pretty_generate(sample).gsub(/^/, ' ') %>
|
31
|
+
```
|
32
|
+
<% else %>
|
33
|
+
The response is empty.
|
18
34
|
<% end %>
|
19
35
|
|
20
36
|
<% end %>
|
@@ -36,15 +36,15 @@ module Restspec
|
|
36
36
|
# - **example**: A callable object (eg: a lambda) that returns something.
|
37
37
|
# - **for**: Defines what abilities this attributes has.
|
38
38
|
# This is an array that can contains none, some or all the symbols
|
39
|
-
# `:
|
40
|
-
# allowing the attribute to be used for run validations from {Checker#check!}
|
41
|
-
# and for generating
|
39
|
+
# `:response` and `:payload`. This option defaults to `[:response, :payload]`,
|
40
|
+
# allowing the attribute to be used for run validations from {Checker#check!} (`:response`)
|
41
|
+
# and for generating payload from {SchemaExample#value} (`:payload`).
|
42
42
|
# @return A new instance of Attribtue.
|
43
43
|
def initialize(name, type, options = {})
|
44
44
|
self.name = name
|
45
45
|
self.type = type
|
46
46
|
self.example_override = options.fetch(:example, nil)
|
47
|
-
self.allowed_abilities = options.fetch(:for, [:
|
47
|
+
self.allowed_abilities = options.fetch(:for, [:response, :payload])
|
48
48
|
end
|
49
49
|
|
50
50
|
# The inner example in the attribute created calling the :example option
|
@@ -55,14 +55,14 @@ module Restspec
|
|
55
55
|
@example ||= example_override
|
56
56
|
end
|
57
57
|
|
58
|
-
# @return [true, false] if the attribute has the ability to
|
59
|
-
def
|
60
|
-
allowed_abilities.include?(:
|
58
|
+
# @return [true, false] if the attribute has the ability to be used in payloads.
|
59
|
+
def can_be_checked?
|
60
|
+
allowed_abilities.include?(:payload)
|
61
61
|
end
|
62
62
|
|
63
|
-
# @return [true, false] if the attribute has the ability
|
64
|
-
def
|
65
|
-
allowed_abilities.include?(
|
63
|
+
# @return [true, false] if the attribute has the ability being passed
|
64
|
+
def can?(ability)
|
65
|
+
allowed_abilities.include?(ability)
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
data/lib/restspec/schema/dsl.rb
CHANGED
@@ -10,6 +10,10 @@ module Restspec
|
|
10
10
|
# The set of attributes that conforms the schema.
|
11
11
|
attr_reader :attributes
|
12
12
|
|
13
|
+
# TODO: Document
|
14
|
+
attr_accessor :intention
|
15
|
+
attr_accessor :original_schema
|
16
|
+
|
13
17
|
# @param name [Symbol] The name of the schema
|
14
18
|
# @return a new {Restspec::Schema::Schema Schema} object
|
15
19
|
def initialize(name)
|
@@ -25,6 +29,14 @@ module Restspec
|
|
25
29
|
self
|
26
30
|
end
|
27
31
|
|
32
|
+
def attributes_for_intention
|
33
|
+
return attributes if intention.blank?
|
34
|
+
|
35
|
+
attributes.inject({}) do |hash, (name, attribute)|
|
36
|
+
attribute.can?(intention) ? hash.merge(name => attribute) : hash
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
28
40
|
private
|
29
41
|
|
30
42
|
attr_writer :name, :attributes
|
@@ -16,18 +16,14 @@ module Restspec
|
|
16
16
|
# @return [Restspec::Values::SuperHash] generated example.
|
17
17
|
def value
|
18
18
|
attributes.inject({}) do |sample, (_, attribute)|
|
19
|
-
|
20
|
-
sample.merge(attribute.name => AttributeExample.new(attribute).value)
|
21
|
-
else
|
22
|
-
sample
|
23
|
-
end
|
19
|
+
sample.merge(attribute.name => AttributeExample.new(attribute).value)
|
24
20
|
end.merge(extensions)
|
25
21
|
end
|
26
22
|
|
27
23
|
private
|
28
24
|
|
29
25
|
def attributes
|
30
|
-
schema.
|
26
|
+
schema.attributes_for_intention
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
data/lib/restspec/version.rb
CHANGED
data/restspec.gemspec
CHANGED
@@ -14,20 +14,6 @@ describe Attribute do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe '#can_generate_examples?' do
|
18
|
-
subject { attribute.can_generate_examples? }
|
19
|
-
|
20
|
-
context 'without the option' do
|
21
|
-
let(:attribute) { Attribute.new(:name, type, example: 'example', :for => []) }
|
22
|
-
it { should eq(false) }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with the option' do
|
26
|
-
let(:attribute) { Attribute.new(:name, type, example: 'example', :for => [:examples]) }
|
27
|
-
it { should eq(true) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
17
|
describe '#can_be_checked?' do
|
32
18
|
subject { attribute.can_be_checked? }
|
33
19
|
|
@@ -37,7 +23,7 @@ describe Attribute do
|
|
37
23
|
end
|
38
24
|
|
39
25
|
context 'with the option' do
|
40
|
-
let(:attribute) { Attribute.new(:name, type, :for => [:
|
26
|
+
let(:attribute) { Attribute.new(:name, type, :for => [:payload]) }
|
41
27
|
it { should eq(true) }
|
42
28
|
end
|
43
29
|
end
|
@@ -50,30 +50,6 @@ describe SingleSchemaDSL do
|
|
50
50
|
expect(attribute.name).to eq('attr_name')
|
51
51
|
expect(attribute.type).to eq(type_instance)
|
52
52
|
end
|
53
|
-
|
54
|
-
context 'when the :for option is just for checks' do
|
55
|
-
let(:attribute) { dsl.attribute('attr_name', type_instance, for: [:checks]) }
|
56
|
-
|
57
|
-
it 'is not allowed to generate examples' do
|
58
|
-
expect(attribute.can_generate_examples?).to eq(false)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'is allowed to run in validations' do
|
62
|
-
expect(attribute.can_be_checked?).to eq(true)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'when the :for option is just for examples' do
|
67
|
-
let(:attribute) { dsl.attribute('attr_name', type_instance, for: [:examples]) }
|
68
|
-
|
69
|
-
it 'is allowed to generate examples' do
|
70
|
-
expect(attribute.can_generate_examples?).to eq(true)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'is not allowed to run in validations' do
|
74
|
-
expect(attribute.can_be_checked?).to eq(false)
|
75
|
-
end
|
76
|
-
end
|
77
53
|
end
|
78
54
|
|
79
55
|
describe '#include_attributes' do
|
@@ -19,16 +19,6 @@ describe SchemaExample do
|
|
19
19
|
let(:schema_example) { SchemaExample.new(schema) }
|
20
20
|
|
21
21
|
it { should eq(name: 'name', age: 18)}
|
22
|
-
|
23
|
-
context 'with an attribute not allowed to generate examples' do
|
24
|
-
before do
|
25
|
-
schema.attributes['hidden'] = Attribute.new(:hidden, hidden_type, :for => [:checks])
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'does not include the hidden attribute' do
|
29
|
-
expect(subject).to_not include(:hidden)
|
30
|
-
end
|
31
|
-
end
|
32
22
|
end
|
33
23
|
|
34
24
|
context 'with extensions' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juliogarciag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -262,6 +262,20 @@ dependencies:
|
|
262
262
|
- - ~>
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '2.0'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: ruby_deep_clone
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ~>
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0.6'
|
272
|
+
type: :runtime
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ~>
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0.6'
|
265
279
|
description: RSpec macros, helpers and matchers to work with APIs
|
266
280
|
email:
|
267
281
|
- julioggonz@gmail.com
|